diff options
author | Max Horn | 2011-05-23 19:09:34 +0200 |
---|---|---|
committer | Max Horn | 2011-05-23 19:12:26 +0200 |
commit | 590c6ede63d9fa61d2b05ce74596b043f5c79bc8 (patch) | |
tree | f379b55db87e4bd70aca1958e89a3d2a1fd657eb /backends | |
parent | e6c78b4f469729726561af44aa1df8259f0fdf27 (diff) | |
download | scummvm-rg350-590c6ede63d9fa61d2b05ce74596b043f5c79bc8.tar.gz scummvm-rg350-590c6ede63d9fa61d2b05ce74596b043f5c79bc8.tar.bz2 scummvm-rg350-590c6ede63d9fa61d2b05ce74596b043f5c79bc8.zip |
BACKENDS: Move SCUMMVM_SAVEPATH env var handling to POSIX savefile manager
Diffstat (limited to 'backends')
-rw-r--r-- | backends/saves/posix/posix-saves.cpp | 24 |
1 files changed, 23 insertions, 1 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 } /* |