Let $XDG_CONFIG_HOME fallback to $HOME/.config.

Use the specification more correctly. Keep fallback to
$HOME/.retroarch.cfg.
This commit is contained in:
Themaister 2013-02-26 18:46:07 +01:00
parent 5b2a5c76b5
commit 7fadee0da3
3 changed files with 20 additions and 21 deletions

View File

@ -73,7 +73,7 @@ When loading a rom from stdin, the path must be a full path, however.
If a config cannot be found when using directory path, the default config path will be used instead.
.IP
Unix-like systems will look in $XDG_CONFIG_HOME/retroarch/retroarch.cfg first. Then it will try $HOME/.retroarch.cfg. Last, it will try /etc/retroarch.cfg. If no configuration is found, default settings will be assumed. A configuration file does not need to define every possible option, only those that should be overridden.
Unix-like systems will look in $XDG_CONFIG_HOME/retroarch/retroarch.cfg first. If $XDG_CONFIG_HOME is not defined, it is assumed to be $HOME/.config as per specification. Then it will try $HOME/.retroarch.cfg. Last, it will try /etc/retroarch.cfg. If no configuration is found, default settings will be assumed. A configuration file does not need to define every possible option, only those that should be overridden.
.IP
Windows will look in retroarch.cfg in same folder where retroarch.exe resides.

View File

@ -569,10 +569,8 @@ static int16_t input_state(unsigned port, unsigned device, unsigned index, unsig
#ifdef _WIN32
#define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tDefaults to retroarch.cfg in same directory as retroarch.exe."
#elif defined(__APPLE__)
#define RARCH_DEFAULT_CONF_PATH_STR " Defaults to $HOME/.retroarch.cfg."
#else
#define RARCH_DEFAULT_CONF_PATH_STR " Defaults to $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\tor $HOME/.retroarch.cfg, if $XDG_CONFIG_HOME is not defined."
#define RARCH_DEFAULT_CONF_PATH_STR "\n\t\tBy default looks for config in $XDG_CONFIG_HOME/retroarch/retroarch.cfg,\n\t\t$HOME/.config/retroarch/retroarch.cfg,\n\t\tand $HOME/.retroarch.cfg."
#endif
#include "config.features.h"

View File

@ -329,36 +329,37 @@ static config_file_t *open_default_config_file(void)
conf = config_file_new(conf_path);
}
}
#elif defined(__APPLE__)
char conf_path[PATH_MAX];
const char *home = getenv("HOME");
if (home)
{
snprintf(conf_path, sizeof(conf_path), "%s/.retroarch.cfg", home);
conf = config_file_new(conf_path);
}
if (!conf)
conf = config_file_new("/etc/retroarch.cfg");
#elif !defined(__CELLOS_LV2__) && !defined(_XBOX)
char conf_path[PATH_MAX];
const char *xdg = getenv("XDG_CONFIG_HOME");
if (!xdg)
RARCH_WARN("XDG_CONFIG_HOME is not defined. Will look for config in $HOME/.retroarch.cfg ...\n");
const char *xdg = getenv("XDG_CONFIG_HOME");
const char *home = getenv("HOME");
// XDG_CONFIG_HOME falls back to $HOME/.config.
if (xdg)
{
snprintf(conf_path, sizeof(conf_path), "%s/retroarch/retroarch.cfg", xdg);
else if (home)
snprintf(conf_path, sizeof(conf_path), "%s/.config/retroarch/retroarch.cfg", home);
if (xdg || home)
{
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
conf = config_file_new(conf_path);
}
else if (home)
// Fallback to $HOME/.retroarch.cfg.
if (!conf && home)
{
snprintf(conf_path, sizeof(conf_path), "%s/.retroarch.cfg", home);
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
conf = config_file_new(conf_path);
}
// Try this as a last chance...
// Try this as a last chance ...
if (!conf)
{
conf = config_file_new("/etc/retroarch.cfg");
RARCH_LOG("Looking for config in: \"/etc/retroarch.cfg\".\n");
}
#endif
return conf;