aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/saves/posix/posix-saves.cpp24
-rw-r--r--base/commandLine.cpp20
2 files changed, 23 insertions, 21 deletions
diff --git a/backends/saves/posix/posix-saves.cpp b/backends/saves/posix/posix-saves.cpp
index d82f8a1845..37545c77c2 100644
--- a/backends/saves/posix/posix-saves.cpp
+++ b/backends/saves/posix/posix-saves.cpp
@@ -21,7 +21,8 @@
*/
-// Enable mkdir
+// Enable getenv, mkdir and time.h stuff
+#define FORBIDDEN_SYMBOL_EXCEPTION_getenv
#define FORBIDDEN_SYMBOL_EXCEPTION_mkdir
#define FORBIDDEN_SYMBOL_EXCEPTION_time_h //On IRIX, sys/stat.h includes sys/time.h
@@ -59,6 +60,27 @@ POSIXSaveFileManager::POSIXSaveFileManager() {
savePath += "/" DEFAULT_SAVE_PATH;
ConfMan.registerDefault("savepath", savePath);
}
+
+ // The user can override the savepath with the SCUMMVM_SAVEPATH
+ // environment variable. This is weaker than a --savepath on the
+ // command line, but overrides the default savepath.
+ //
+ // To ensure that the command line option (if given) has precedence,
+ // we only set the value in the transient domain if it is not
+ // yet present there.
+ if (!ConfMan.hasKey("savepath", Common::ConfigManager::kTransientDomain)) {
+ const char *dir = getenv("SCUMMVM_SAVEPATH");
+ if (dir && *dir && strlen(dir) < MAXPATHLEN) {
+ Common::FSNode saveDir(dir);
+ if (!saveDir.exists()) {
+ warning("Ignoring non-existent SCUMMVM_SAVEPATH '%s'", dir);
+ } else if (!saveDir.isWritable()) {
+ warning("Ignoring non-writable SCUMMVM_SAVEPATH '%s'", dir);
+ } else {
+ ConfMan.set("savepath", dir, Common::ConfigManager::kTransientDomain);
+ }
+ }
+ }
#endif
}
/*
diff --git a/base/commandLine.cpp b/base/commandLine.cpp
index 1ca4a642c8..f819b03658 100644
--- a/base/commandLine.cpp
+++ b/base/commandLine.cpp
@@ -958,26 +958,6 @@ Common::Error processSettings(Common::String &command, Common::StringMap &settin
}
- // The user can override the savepath with the SCUMMVM_SAVEPATH
- // environment variable. This is weaker than a --savepath on the
- // command line, but overrides the default savepath, hence it is
- // handled here, just before the command line gets parsed.
-#if !defined(_WIN32_WCE) && !defined(__GP32__) && !defined(ANDROID)
- if (!settings.contains("savepath")) {
- const char *dir = getenv("SCUMMVM_SAVEPATH");
- if (dir && *dir && strlen(dir) < MAXPATHLEN) {
- Common::FSNode saveDir(dir);
- if (!saveDir.exists()) {
- warning("Non-existent SCUMMVM_SAVEPATH save path. It will be ignored");
- } else if (!saveDir.isWritable()) {
- warning("Non-writable SCUMMVM_SAVEPATH save path. It will be ignored");
- } else {
- settings["savepath"] = dir;
- }
- }
- }
-#endif
-
// Finally, store the command line settings into the config manager.
for (Common::StringMap::const_iterator x = settings.begin(); x != settings.end(); ++x) {
Common::String key(x->_key);