diff options
author | Nicola Mettifogo | 2007-12-10 18:59:18 +0000 |
---|---|---|
committer | Nicola Mettifogo | 2007-12-10 18:59:18 +0000 |
commit | cd740a547471f080cd60f44c85ce4c7112e42d1b (patch) | |
tree | 8d3ae67764753e453a8acba07133c77e04b7329c | |
parent | f625562aff39af1150bd941cf56c50ea0d1f52e6 (diff) | |
download | scummvm-rg350-cd740a547471f080cd60f44c85ce4c7112e42d1b.tar.gz scummvm-rg350-cd740a547471f080cd60f44c85ce4c7112e42d1b.tar.bz2 scummvm-rg350-cd740a547471f080cd60f44c85ce4c7112e42d1b.zip |
When renaming a savefile, close the old file before deleting it to avoid errors.
svn-id: r29818
-rw-r--r-- | backends/saves/savefile.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/backends/saves/savefile.cpp b/backends/saves/savefile.cpp index 8466130151..59ad144159 100644 --- a/backends/saves/savefile.cpp +++ b/backends/saves/savefile.cpp @@ -51,7 +51,11 @@ bool SaveFileManager::renameSavefile(const char *oldFilename, const char *newFil if (buffer && outFile) { inFile->read(buffer, size); - if (!inFile->ioFailed()) { + bool error = inFile->ioFailed(); + delete inFile; + inFile = 0; + + if (!error) { outFile->write(buffer, size); outFile->finalize(); if (!outFile->ioFailed()) { @@ -59,7 +63,7 @@ bool SaveFileManager::renameSavefile(const char *oldFilename, const char *newFil } } } - + free(buffer); delete outFile; delete inFile; |