aboutsummaryrefslogtreecommitdiff
path: root/backends/saves/default/default-saves.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'backends/saves/default/default-saves.cpp')
-rw-r--r--backends/saves/default/default-saves.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp
index 69af78404d..70b9977d8f 100644
--- a/backends/saves/default/default-saves.cpp
+++ b/backends/saves/default/default-saves.cpp
@@ -55,11 +55,14 @@ void DefaultSaveFileManager::checkPath(const Common::FSNode &dir) {
}
Common::StringList DefaultSaveFileManager::listSavefiles(const Common::String &pattern) {
- Common::FSNode savePath(getSavePath());
- checkPath(savePath);
+ Common::String savePathName = getSavePath();
+ checkPath(Common::FSNode(savePathName));
if (getError() != Common::kNoError)
return Common::StringList();
+ // recreate FSNode since checkPath may have changed/created the directory
+ Common::FSNode savePath(savePathName);
+
Common::FSDirectory dir(savePath);
Common::ArchiveMemberList savefiles;
Common::StringList results;
@@ -76,11 +79,14 @@ Common::StringList DefaultSaveFileManager::listSavefiles(const Common::String &p
Common::InSaveFile *DefaultSaveFileManager::openForLoading(const Common::String &filename) {
// Ensure that the savepath is valid. If not, generate an appropriate error.
- Common::FSNode savePath(getSavePath());
- checkPath(savePath);
+ Common::String savePathName = getSavePath();
+ checkPath(Common::FSNode(savePathName));
if (getError() != Common::kNoError)
return 0;
+ // recreate FSNode since checkPath may have changed/created the directory
+ Common::FSNode savePath(savePathName);
+
Common::FSNode file = savePath.getChild(filename);
if (!file.exists())
return 0;
@@ -93,11 +99,14 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const Common::String
Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String &filename) {
// Ensure that the savepath is valid. If not, generate an appropriate error.
- Common::FSNode savePath(getSavePath());
- checkPath(savePath);
+ Common::String savePathName = getSavePath();
+ checkPath(Common::FSNode(savePathName));
if (getError() != Common::kNoError)
return 0;
+ // recreate FSNode since checkPath may have changed/created the directory
+ Common::FSNode savePath(savePathName);
+
Common::FSNode file = savePath.getChild(filename);
// Open the file for saving
@@ -107,13 +116,14 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String
}
bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) {
- clearError();
-
- Common::FSNode savePath(getSavePath());
- checkPath(savePath);
+ Common::String savePathName = getSavePath();
+ checkPath(Common::FSNode(savePathName));
if (getError() != Common::kNoError)
return false;
+ // recreate FSNode since checkPath may have changed/created the directory
+ Common::FSNode savePath(savePathName);
+
Common::FSNode file = savePath.getChild(filename);
// FIXME: remove does not exist on all systems. If your port fails to