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 
31 namespace Common {
32 
48 
55 protected:
58 public:
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 
144 protected:
153  virtual void setError(Error error, const String &errorDesc) { _error = error; _errorDesc = errorDesc; }
154 
155 public:
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 
183  virtual String popErrorDesc();
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: str.h:59
Error _error
Definition: savefile.h:145
Definition: stream.h:77
Definition: savefile.h:54
Definition: error.h:84
void clearErr() override
OutSaveFile(WriteStream *w)
virtual Error getError()
Definition: savefile.h:168
bool err() const override
No error occurred.
Definition: error.h:48
int64 size() const override
Definition: stream.h:745
Definition: noncopyable.h:39
void finalize() override
String _errorDesc
Definition: savefile.h:146
WriteStream * _wrapped
Definition: savefile.h:56
Definition: algorithm.h:29
bool seek(int64 offset, int whence) override
void NORETURN_PRE error(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
virtual void clearError()
Definition: savefile.h:161
uint32 write(const void *dataPtr, uint32 dataSize) override
Definition: stream.h:351
virtual String getErrorDesc()
Definition: savefile.h:175
virtual void setError(Error error, const String &errorDesc)
Definition: savefile.h:153
SeekableReadStream InSaveFile
Definition: savefile.h:47
Definition: savefile.h:142
bool flush() override
int64 pos() const override