diff options
author | Littleboy | 2011-03-21 12:24:16 -0400 |
---|---|---|
committer | Littleboy | 2011-03-24 18:51:58 -0400 |
commit | 5a1874e3d946002c21af9ed315f762bfb467ef3f (patch) | |
tree | 6bcf009281413f4977fc48695b501fafc72821df /backends | |
parent | b95013dfe25d75d39c7deb69ee1a63f93a4a495f (diff) | |
download | scummvm-rg350-5a1874e3d946002c21af9ed315f762bfb467ef3f.tar.gz scummvm-rg350-5a1874e3d946002c21af9ed315f762bfb467ef3f.tar.bz2 scummvm-rg350-5a1874e3d946002c21af9ed315f762bfb467ef3f.zip |
COMMON: Add SaveFileManager::copySavefile() and update SaveFileManager::renameSavefile() to use it
Diffstat (limited to 'backends')
-rw-r--r-- | backends/saves/savefile.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/backends/saves/savefile.cpp b/backends/saves/savefile.cpp index d2fc913f14..7b7d6b0c0c 100644 --- a/backends/saves/savefile.cpp +++ b/backends/saves/savefile.cpp @@ -31,8 +31,7 @@ namespace Common { -bool SaveFileManager::renameSavefile(const String &oldFilename, const String &newFilename) { - +bool SaveFileManager::copySavefile(const String &oldFilename, const String &newFilename) { InSaveFile *inFile = 0; OutSaveFile *outFile = 0; uint32 size = 0; @@ -57,9 +56,8 @@ bool SaveFileManager::renameSavefile(const String &oldFilename, const String &ne if (!error) { outFile->write(buffer, size); outFile->finalize(); - if (!outFile->err()) { - success = removeSavefile(oldFilename); - } + + success = !outFile->err(); } } @@ -71,6 +69,13 @@ bool SaveFileManager::renameSavefile(const String &oldFilename, const String &ne return success; } +bool SaveFileManager::renameSavefile(const String &oldFilename, const String &newFilename) { + if (!copySavefile(oldFilename, newFilename)) + return false; + + return removeSavefile(oldFilename); +} + String SaveFileManager::popErrorDesc() { String err = _errorDesc; clearError(); |