From 1462efb52dcdfb033f15c0c987bc49d64fdf73d8 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 10 Jul 2009 22:29:25 +0000 Subject: 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 --- backends/saves/default/default-saves.cpp | 30 ++++++++++++++++++++---------- 1 file 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 -- cgit v1.2.3