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
This commit is contained in:
Willem Jan Palenstijn 2009-07-10 22:29:25 +00:00
parent 1f24fe43a2
commit 1462efb52d

View file

@ -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