aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/saves/default/default-saves.cpp12
-rw-r--r--backends/saves/default/default-saves.h1
-rw-r--r--common/savefile.h7
3 files changed, 17 insertions, 3 deletions
diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp
index f41455be3f..299c528e46 100644
--- a/backends/saves/default/default-saves.cpp
+++ b/backends/saves/default/default-saves.cpp
@@ -29,7 +29,7 @@
#include "common/savefile.h"
#include "common/util.h"
#include "common/fs.h"
-#include "common/str.h"
+#include "common/file.h"
#include "backends/saves/default/default-saves.h"
#include "backends/saves/compressed/compressed-saves.h"
@@ -180,10 +180,10 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename)
break;
}
} else {
- // So stat() succeeded. But is the path actually pointing to a
- // directory?
+ // So stat() succeeded. But is the path actually pointing to a directory?
if (!S_ISDIR(sb.st_mode)) {
setError(SFM_DIR_NOTDIR, Common::String("The given savepath is not a directory"));
+
return 0;
}
}
@@ -215,6 +215,12 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename)
return wrapInSaveFile(sf);
}
+bool DefaultSaveFileManager::removeSavefile(const char *filename) {
+ Common::File file;
+ FilesystemNode savePath(filename);
+ return file.remove(savePath);
+}
+
Common::StringList DefaultSaveFileManager::listSavefiles(const char *regex) {
FilesystemNode savePath(getSavePath());
FSList savefiles;
diff --git a/backends/saves/default/default-saves.h b/backends/saves/default/default-saves.h
index 4b525cabc8..2baddd1335 100644
--- a/backends/saves/default/default-saves.h
+++ b/backends/saves/default/default-saves.h
@@ -34,6 +34,7 @@ class DefaultSaveFileManager : public Common::SaveFileManager {
public:
virtual Common::OutSaveFile *openForSaving(const char *filename);
virtual Common::InSaveFile *openForLoading(const char *filename);
+ virtual bool removeSavefile(const char *filename);
virtual Common::StringList listSavefiles(const char *regex);
};
diff --git a/common/savefile.h b/common/savefile.h
index 7c97ea5058..3e1b9ffaaa 100644
--- a/common/savefile.h
+++ b/common/savefile.h
@@ -137,6 +137,13 @@ public:
virtual InSaveFile *openForLoading(const char *filename) = 0;
/**
+ * Removes the given savefile from the filesystem.
+ * @param filename Filename path pointing to the savefile.
+ * @return true if no error ocurred. false otherwise.
+ */
+ virtual bool removeSavefile(const char *filename) = 0;
+
+ /**
* Request a list of available savegames with a given regex.
* @param regex Regular expression to match. Wildcards like * or ? are available.
* returns a list of strings for all present file names.