diff options
author | Willem Jan Palenstijn | 2009-07-10 22:29:25 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2009-07-10 22:29:25 +0000 |
commit | 1462efb52dcdfb033f15c0c987bc49d64fdf73d8 (patch) | |
tree | 50d30f4bc4c939664f6a905109ebb1c16487fc51 | |
parent | 1f24fe43a237f606f801d7ae97effef957463eb4 (diff) | |
download | scummvm-rg350-1462efb52dcdfb033f15c0c987bc49d64fdf73d8.tar.gz scummvm-rg350-1462efb52dcdfb033f15c0c987bc49d64fdf73d8.tar.bz2 scummvm-rg350-1462efb52dcdfb033f15c0c987bc49d64fdf73d8.zip |
Recreate FSNode after calling checkPath since checkPath may
have created the directory the FSNode points to, invalidating
its cached metadata. In the future, it might be nice to add
a FSNode::rescan() function for this? This fixes #2793187 .
svn-id: r42357
-rw-r--r-- | backends/saves/default/default-saves.cpp | 30 |
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 |