ScummVM API documentation
file.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef COMMON_FILE_H
23 #define COMMON_FILE_H
24 
25 #include "common/scummsys.h"
26 #include "common/fs.h"
27 #include "common/noncopyable.h"
28 #include "common/str.h"
29 #include "common/stream.h"
30 
31 namespace Common {
32 
42 class Archive;
43 
47 class File : public SeekableReadStream, public NonCopyable {
48 protected:
51 
54 
55 public:
56  File();
57  virtual ~File();
58 
66  static bool exists(const Path &filename);
67 
75  virtual bool open(const Path &filename);
76 
85  virtual bool open(const Path &filename, Archive &archive);
86 
96  virtual bool open(const FSNode &node);
97 
107  virtual bool open(SeekableReadStream *stream, const String &name);
108 
112  virtual void close();
113 
119  bool isOpen() const;
120 
126  const char *getName() const { return _name.c_str(); }
127 
128  bool err() const override;
129  void clearErr() override;
130  bool eos() const override;
132  int64 pos() const override;
133  int64 size() const override;
134  bool seek(int64 offs, int whence = SEEK_SET) override;
135  uint32 read(void *dataPtr, uint32 dataSize) override;
136 };
137 
138 
145 class DumpFile : public SeekableWriteStream, public NonCopyable {
146 protected:
149 
150 public:
151  DumpFile();
152  virtual ~DumpFile();
153 
154  virtual bool open(const Path &filename, bool createPath = false);
155  virtual bool open(const FSNode &node);
156 
157  virtual void close();
158 
164  bool isOpen() const;
165 
166  bool err() const override;
167  void clearErr() override;
168 
169  uint32 write(const void *dataPtr, uint32 dataSize) override;
170 
171  bool flush() override;
172 
173  int64 pos() const override;
174 
175  bool seek(int64 offset, int whence = SEEK_SET) override;
176  int64 size() const override;
177 };
178 
181 } // End of namespace Common
182 
183 #endif
uint32 read(void *dataPtr, uint32 dataSize) override
Definition: str.h:59
Definition: stream.h:77
virtual bool open(const Path &filename)
Definition: path.h:52
String _name
Definition: file.h:53
Definition: stream.h:745
Definition: file.h:145
Definition: archive.h:141
Definition: noncopyable.h:39
const char * getName() const
Definition: file.h:126
SeekableReadStream * _handle
Definition: file.h:50
Definition: file.h:47
int64 size() const override
Definition: algorithm.h:29
Definition: fs.h:69
void clearErr() override
virtual void close()
bool isOpen() const
bool eos() const override
static bool exists(const Path &filename)
Definition: stream.h:351
int64 pos() const override
bool err() const override
WriteStream * _handle
Definition: file.h:148
bool seek(int64 offs, int whence=SEEK_SET) override