mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-02 08:19:19 +00:00
BACKENDS: Extend OutSaveFile to support SeekableWriteStream
The seek and size methods of SeekableWriteStream are only supported when creating uncompressed save files.
This commit is contained in:
parent
9db14ee109
commit
be06c4eb8a
@ -56,6 +56,30 @@ int64 OutSaveFile::pos() const {
|
||||
return _wrapped->pos();
|
||||
}
|
||||
|
||||
bool OutSaveFile::seek(int64 offset, int whence) {
|
||||
Common::SeekableWriteStream *sws =
|
||||
dynamic_cast<Common::SeekableWriteStream *>(_wrapped);
|
||||
|
||||
if (sws) {
|
||||
return sws->seek(offset, whence);
|
||||
} else {
|
||||
warning("Seeking isn't supported for compressed save files");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
int64 OutSaveFile::size() const {
|
||||
Common::SeekableWriteStream *sws =
|
||||
dynamic_cast<Common::SeekableWriteStream *>(_wrapped);
|
||||
|
||||
if (sws) {
|
||||
return sws->size();
|
||||
} else {
|
||||
warning("Size isn't supported for compressed save files");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool SaveFileManager::copySavefile(const String &oldFilename, const String &newFilename, bool compress) {
|
||||
InSaveFile *inFile = 0;
|
||||
OutSaveFile *outFile = 0;
|
||||
|
@ -52,7 +52,7 @@ typedef SeekableReadStream InSaveFile;
|
||||
* That typically means "save games", but also includes things like the
|
||||
* IQ points in Indy3.
|
||||
*/
|
||||
class OutSaveFile: public WriteStream {
|
||||
class OutSaveFile: public SeekableWriteStream {
|
||||
protected:
|
||||
WriteStream *_wrapped; /*!< @todo Doc required. */
|
||||
|
||||
@ -107,6 +107,18 @@ public:
|
||||
* @return The current position indicator, or -1 if an error occurred.
|
||||
*/
|
||||
virtual int64 pos() const;
|
||||
|
||||
/**
|
||||
* Seeks to a new position within the file.
|
||||
* This is only supported when creating uncompressed save files.
|
||||
*/
|
||||
bool seek(int64 offset, int whence) override;
|
||||
|
||||
/**
|
||||
* Returns the size of the save file
|
||||
* This is only supported when creating uncompressed save files.
|
||||
*/
|
||||
int64 size() const override;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user