POSIX: Move default config file location to '$XDG_CONFIG_HOME/scummvm/scummvm.ini'.
This is what the XDG Base Directory Specification suggests to use. We still use the old location of '~/.scummvmrc' in case that is present. This tackles an aspect of bug #6036 "POSIX: Use XDG dirs instead of HOME".
This commit is contained in:
parent
79acfd28e9
commit
dde89c36f5
3 changed files with 58 additions and 7 deletions
10
README
10
README
|
@ -2329,7 +2329,15 @@ By default, the configuration file is saved in, and loaded from:
|
|||
previous default location of '<windir>\scummvm.ini' will be kept.
|
||||
|
||||
Unix:
|
||||
~/.scummvmrc
|
||||
We follow the XDG Base Directory Specification. This means our
|
||||
configuration can be found in:
|
||||
$XDG_CONFIG_HOME/scummvm/scummvm.ini
|
||||
|
||||
If XDG_CONFIG_HOME is not defined or empty, '~/.config' will be used
|
||||
as value for XDG_CONFIG_HOME in accordance with the specification.
|
||||
|
||||
If an earlier version of ScummVM was installed on your system, the
|
||||
previous default location of '~/.scummvmrc' will be kept.
|
||||
|
||||
Mac OS X:
|
||||
~/Library/Preferences/ScummVM Preferences
|
||||
|
|
|
@ -150,11 +150,54 @@ bool OSystem_POSIX::hasFeature(Feature f) {
|
|||
Common::String OSystem_POSIX::getDefaultConfigFileName() {
|
||||
Common::String configFile;
|
||||
|
||||
// On POSIX type systems, by default we store the config file inside
|
||||
// to the HOME directory of the user.
|
||||
const char *home = getenv("HOME");
|
||||
if (home != NULL && (strlen(home) + 1 + _baseConfigName.size()) < MAXPATHLEN) {
|
||||
configFile = Common::String::format("%s/%s", home, _baseConfigName.c_str());
|
||||
Common::String prefix;
|
||||
#ifdef MACOSX
|
||||
prefix = getenv("HOME");
|
||||
#elif !defined(SAMSUNGTV)
|
||||
const char *envVar;
|
||||
// Our old configuration file path for POSIX systems was ~/.scummvmrc.
|
||||
// If that file exists, we still use it.
|
||||
envVar = getenv("HOME");
|
||||
if (envVar && *envVar) {
|
||||
configFile = envVar;
|
||||
configFile += '/';
|
||||
configFile += ".scummvmrc";
|
||||
|
||||
if (configFile.size() < MAXPATHLEN) {
|
||||
struct stat sb;
|
||||
if (stat(configFile.c_str(), &sb) == 0) {
|
||||
return configFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// On POSIX systems we follow the XDG Base Directory Specification for
|
||||
// where to store files. The version we based our code upon can be found
|
||||
// over here: http://standards.freedesktop.org/basedir-spec/basedir-spec-0.8.html
|
||||
envVar = getenv("XDG_CONFIG_HOME");
|
||||
if (!envVar || !*envVar) {
|
||||
envVar = getenv("HOME");
|
||||
if (!envVar) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (assureDirectoryExists(".config", envVar)) {
|
||||
prefix = envVar;
|
||||
prefix += "/.config";
|
||||
}
|
||||
} else {
|
||||
prefix = envVar;
|
||||
}
|
||||
|
||||
if (!prefix.empty() && assureDirectoryExists("scummvm", prefix.c_str())) {
|
||||
prefix += "/scummvm";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!prefix.empty() && (prefix.size() + 1 + _baseConfigName.size()) < MAXPATHLEN) {
|
||||
configFile = prefix;
|
||||
configFile += '/';
|
||||
configFile += _baseConfigName;
|
||||
} else {
|
||||
configFile = _baseConfigName;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
class OSystem_POSIX : public OSystem_SDL {
|
||||
public:
|
||||
// Let the subclasses be able to change _baseConfigName in the constructor
|
||||
OSystem_POSIX(Common::String baseConfigName = ".scummvmrc");
|
||||
OSystem_POSIX(Common::String baseConfigName = "scummvm.ini");
|
||||
virtual ~OSystem_POSIX() {}
|
||||
|
||||
virtual bool hasFeature(Feature f);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue