[Scummvm-git-logs] scummvm master -> aac0f40d2cc37a2d5d3f3dec558d3e66f7fee308
bluegr
bluegr at gmail.com
Sun Oct 10 08:39:51 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
aac0f40d2c BACKENDS: Add overloadable removeFile in DefaultSaveFileManager
Commit: aac0f40d2cc37a2d5d3f3dec558d3e66f7fee308
https://github.com/scummvm/scummvm/commit/aac0f40d2cc37a2d5d3f3dec558d3e66f7fee308
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-10-10T11:39:47+03:00
Commit Message:
BACKENDS: Add overloadable removeFile in DefaultSaveFileManager
This allows using the DefaultSaveFileManager on system where
remove() does not exist. See bug #12975.
Changed paths:
backends/saves/default/default-saves.cpp
backends/saves/default/default-saves.h
diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp
index d6129a224c..e84015c7f7 100644
--- a/backends/saves/default/default-saves.cpp
+++ b/backends/saves/default/default-saves.cpp
@@ -205,23 +205,25 @@ bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) {
_saveFileCache.erase(file);
file = _saveFileCache.end();
- // FIXME: remove does not exist on all systems. If your port fails to
- // compile because of this, please let us know (scummvm-devel).
- // There is a nicely portable workaround, too: Make this method overloadable.
- if (remove(fileNode.getPath().c_str()) != 0) {
- if (errno == EACCES)
- setError(Common::kWritePermissionDenied, "Search or write permission denied: "+fileNode.getName());
-
- if (errno == ENOENT)
- setError(Common::kPathDoesNotExist, "removeSavefile: '"+fileNode.getName()+"' does not exist or path is invalid");
-
- return false;
- } else {
+ Common::ErrorCode result = removeFile(fileNode.getPath());
+ if (result == Common::kNoError)
return true;
- }
+ Common::Error error(result);
+ setError(error, "Failed to remove savefile '" + fileNode.getName() + "': " + error.getDesc());
+ return false;
}
}
+Common::ErrorCode DefaultSaveFileManager::removeFile(const Common::String &filepath) {
+ if (remove(filepath.c_str()) == 0)
+ return Common::kNoError;
+ if (errno == EACCES)
+ return Common::kWritePermissionDenied;
+ if (errno == ENOENT)
+ return Common::kPathDoesNotExist;
+ return Common::kUnknownError;
+}
+
bool DefaultSaveFileManager::exists(const Common::String &filename) {
// Assure the savefile name cache is up-to-date.
assureCached(getSavePath());
diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h
index 0557ffdc38..0b3ec657ce 100644
--- a/backends/saves/default/default-saves.h
+++ b/backends/saves/default/default-saves.h
@@ -71,6 +71,12 @@ protected:
*/
virtual void checkPath(const Common::FSNode &dir);
+ /**
+ * Removes the given file.
+ * This is called from removeSavefile() with the full file path.
+ */
+ virtual Common::ErrorCode removeFile(const Common::String &filepath);
+
/**
* Assure that the given save path is cached.
*
More information about the Scummvm-git-logs
mailing list