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
31namespace Common {
32
42class Archive;
43
47class File : public SeekableReadStream, public NonCopyable {
48protected:
51
54
55public:
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
146protected:
149
150public:
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
Definition: archive.h:141
Definition: file.h:145
void clearErr() override
WriteStream * _handle
Definition: file.h:148
bool err() const override
int64 size() const override
int64 pos() const override
bool flush() override
bool isOpen() const
bool seek(int64 offset, int whence=SEEK_SET) override
uint32 write(const void *dataPtr, uint32 dataSize) override
Definition: fs.h:69
Definition: file.h:47
int64 pos() const override
int64 size() const override
bool isOpen() const
bool seek(int64 offs, int whence=SEEK_SET) override
String _name
Definition: file.h:53
bool eos() const override
void clearErr() override
bool err() const override
const char * getName() const
Definition: file.h:126
virtual bool open(const Path &filename, Archive &archive)
virtual void close()
uint32 read(void *dataPtr, uint32 dataSize) override
virtual bool open(SeekableReadStream *stream, const String &name)
static bool exists(const Path &filename)
SeekableReadStream * _handle
Definition: file.h:50
virtual bool open(const FSNode &node)
virtual bool open(const Path &filename)
Definition: noncopyable.h:39
Definition: path.h:52
Definition: stream.h:745
Definition: stream.h:351
Definition: str.h:59
Definition: stream.h:77
Definition: algorithm.h:29