diff options
author | sluicebox | 2019-12-09 22:50:28 -0800 |
---|---|---|
committer | sluicebox | 2019-12-09 22:57:46 -0800 |
commit | baea8d5c9c35aed1ebfde4891c9130dc550a58ad (patch) | |
tree | c94b634d8bdc8af592e2faa3a0b79d878a70538a | |
parent | 099ef8db300fc776539694c766dcb58a4a948952 (diff) | |
download | scummvm-rg350-baea8d5c9c35aed1ebfde4891c9130dc550a58ad.tar.gz scummvm-rg350-baea8d5c9c35aed1ebfde4891c9130dc550a58ad.tar.bz2 scummvm-rg350-baea8d5c9c35aed1ebfde4891c9130dc550a58ad.zip |
COMMON: Make save compression optional when copying
Allows for copying or renaming uncompressed save files, such as
in Phantasmagoria 1, without compressing them in the process.
-rw-r--r-- | backends/saves/savefile.cpp | 8 | ||||
-rw-r--r-- | common/savefile.h | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/backends/saves/savefile.cpp b/backends/saves/savefile.cpp index 059b7dba8d..d3de5f2fbd 100644 --- a/backends/saves/savefile.cpp +++ b/backends/saves/savefile.cpp @@ -56,7 +56,7 @@ int32 OutSaveFile::pos() const { return _wrapped->pos(); } -bool SaveFileManager::copySavefile(const String &oldFilename, const String &newFilename) { +bool SaveFileManager::copySavefile(const String &oldFilename, const String &newFilename, bool compress) { InSaveFile *inFile = 0; OutSaveFile *outFile = 0; uint32 size = 0; @@ -70,7 +70,7 @@ bool SaveFileManager::copySavefile(const String &oldFilename, const String &newF buffer = malloc(size); assert(buffer); - outFile = openForSaving(newFilename); + outFile = openForSaving(newFilename, compress); if (buffer && outFile) { inFile->read(buffer, size); @@ -94,8 +94,8 @@ bool SaveFileManager::copySavefile(const String &oldFilename, const String &newF return success; } -bool SaveFileManager::renameSavefile(const String &oldFilename, const String &newFilename) { - if (!copySavefile(oldFilename, newFilename)) +bool SaveFileManager::renameSavefile(const String &oldFilename, const String &newFilename, bool compress) { + if (!copySavefile(oldFilename, newFilename, compress)) return false; return removeSavefile(oldFilename); diff --git a/common/savefile.h b/common/savefile.h index 80cd03e068..bc76de5659 100644 --- a/common/savefile.h +++ b/common/savefile.h @@ -171,18 +171,22 @@ public: * * @param oldName Old name. * @param newName New name. + * @param compress Toggles whether to compress the resulting save file + * (default) or not. * @return true if no error occurred. false otherwise. */ - virtual bool renameSavefile(const String &oldName, const String &newName); + virtual bool renameSavefile(const String &oldName, const String &newName, bool compress = true); /** * Copy the given savefile. * * @param oldName Old name. * @param newName New name. + * @param compress Toggles whether to compress the resulting save file + * (default) or not. * @return true if no error occurred. false otherwise. */ - virtual bool copySavefile(const String &oldName, const String &newName); + virtual bool copySavefile(const String &oldName, const String &newName, bool compress = true); /** * List available savegames matching a given pattern. |