ScummVM API documentation
savefile.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_SAVEFILE_H
23#define COMMON_SAVEFILE_H
24
25#include "common/noncopyable.h"
26#include "common/scummsys.h"
27#include "common/stream.h"
28#include "common/str-array.h"
29#include "common/error.h"
30
31namespace Common {
32
48
55protected:
58public:
60 virtual ~OutSaveFile();
61
67 bool err() const override;
68
72 void clearErr() override;
73
85 void finalize() override;
86
92 bool flush() override;
93
100 uint32 write(const void *dataPtr, uint32 dataSize) override;
101
108 int64 pos() const override;
109
114 bool seek(int64 offset, int whence) override;
115
120 int64 size() const override;
121};
122
143
144protected:
153 virtual void setError(Error error, const String &errorDesc) { _error = error; _errorDesc = errorDesc; }
154
155public:
156 virtual ~SaveFileManager() {}
157
161 virtual void clearError() { _error = kNoError; _errorDesc.clear(); }
162
168 virtual Error getError() { return _error; }
169
175 virtual String getErrorDesc() { return _errorDesc; }
176
184
202 virtual OutSaveFile *openForSaving(const String &name, bool compress = true) = 0;
203
210 virtual InSaveFile *openForLoading(const String &name) = 0;
211
219 virtual InSaveFile *openRawFile(const String &name) = 0;
220
227 virtual bool removeSavefile(const String &name) = 0;
228
238 virtual bool renameSavefile(const String &oldName, const String &newName, bool compress = true);
239
249 virtual bool copySavefile(const String &oldName, const String &newName, bool compress = true);
250
262 virtual StringArray listSavefiles(const String &pattern) = 0;
263
269 virtual void updateSavefilesList(StringArray &lockedFiles) = 0;
270
278 virtual bool exists(const String &name) = 0;
279};
280
283} // End of namespace Common
284
285#endif
Definition: error.h:81
Definition: noncopyable.h:39
Definition: savefile.h:54
int64 size() const override
WriteStream * _wrapped
Definition: savefile.h:56
void clearErr() override
void finalize() override
bool seek(int64 offset, int whence) override
uint32 write(const void *dataPtr, uint32 dataSize) override
bool err() const override
bool flush() override
int64 pos() const override
OutSaveFile(WriteStream *w)
Definition: savefile.h:142
virtual void setError(Error error, const String &errorDesc)
Definition: savefile.h:153
virtual bool copySavefile(const String &oldName, const String &newName, bool compress=true)
virtual InSaveFile * openRawFile(const String &name)=0
virtual Error getError()
Definition: savefile.h:168
virtual void updateSavefilesList(StringArray &lockedFiles)=0
virtual OutSaveFile * openForSaving(const String &name, bool compress=true)=0
virtual String popErrorDesc()
virtual String getErrorDesc()
Definition: savefile.h:175
virtual void clearError()
Definition: savefile.h:161
virtual bool renameSavefile(const String &oldName, const String &newName, bool compress=true)
virtual StringArray listSavefiles(const String &pattern)=0
String _errorDesc
Definition: savefile.h:146
virtual bool removeSavefile(const String &name)=0
virtual InSaveFile * openForLoading(const String &name)=0
Error _error
Definition: savefile.h:145
virtual bool exists(const String &name)=0
Definition: stream.h:745
Definition: stream.h:351
Definition: str.h:59
Definition: stream.h:77
@ kNoError
No error occurred.
Definition: error.h:48
SeekableReadStream InSaveFile
Definition: savefile.h:47
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
Definition: algorithm.h:29