mirror of
https://github.com/libretro/RetroArch
synced 2025-03-23 19:21:03 +00:00
Add --appendconfig option.
This commit is contained in:
parent
ddcc3119a9
commit
a8ab9c54bc
@ -312,6 +312,23 @@ static bool parse_line(config_file_t *conf, struct entry_list *list, char *line)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool config_append_file(config_file_t *conf, const char *path)
|
||||
{
|
||||
config_file_t *new_conf = config_file_new(path);
|
||||
if (!new_conf)
|
||||
return false;
|
||||
|
||||
if (new_conf->tail)
|
||||
{
|
||||
new_conf->tail->next = conf->entries;
|
||||
conf->entries = new_conf->entries; // Pilfer.
|
||||
new_conf->entries = NULL;
|
||||
}
|
||||
|
||||
config_file_free(new_conf);
|
||||
return true;
|
||||
}
|
||||
|
||||
static config_file_t *config_file_new_internal(const char *path, unsigned depth)
|
||||
{
|
||||
struct config_file *conf = (struct config_file*)calloc(1, sizeof(*conf));
|
||||
|
@ -40,6 +40,10 @@ config_file_t *config_file_new(const char *path);
|
||||
// Frees config file.
|
||||
void config_file_free(config_file_t *conf);
|
||||
|
||||
// Loads a new config, and appends its data to conf.
|
||||
// The key-value pairs of the new config file takes priority over the old.
|
||||
bool config_append_file(config_file_t *conf, const char *path);
|
||||
|
||||
// All extract functions return true when value is valid and exists.
|
||||
// Returns false otherwise.
|
||||
|
||||
|
@ -67,6 +67,12 @@ If PATH is a directory, RetroArch will treat this as the config file directory,
|
||||
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.
|
||||
|
||||
.TP
|
||||
\fB--appendconfig PATH\fR
|
||||
Appends a different set of config files to the config file loaded in -c (or default).
|
||||
Multiple config files are delimited by ','.
|
||||
Every config file will be appended in order where the key-value pairs of the next config file takes priority over the old ones.
|
||||
|
||||
.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.
|
||||
|
||||
|
@ -308,6 +308,7 @@ struct global
|
||||
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
char config_path[PATH_MAX];
|
||||
char append_config_path[PATH_MAX];
|
||||
#endif
|
||||
|
||||
char basename[PATH_MAX];
|
||||
|
@ -594,6 +594,8 @@ static void print_help(void)
|
||||
puts("\t-S/--savestate: Path to use for save states. If not selected, *.state will be assumed.");
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
puts("\t-c/--config: Path for config file." RARCH_DEFAULT_CONF_PATH_STR);
|
||||
puts("\t--appendconfig: Extra config files are loaded in, and take priority over config selected in -c (or default).");
|
||||
puts("\t\tMultiple configs are delimited by ','.");
|
||||
#endif
|
||||
#ifdef HAVE_DYNAMIC
|
||||
puts("\t-L/--libretro: Path to libretro implementation. Overrides any config setting.");
|
||||
@ -768,6 +770,7 @@ static void parse_input(int argc, char *argv[])
|
||||
{ "gameboy", 1, NULL, 'g' },
|
||||
#ifdef HAVE_CONFIGFILE
|
||||
{ "config", 1, NULL, 'c' },
|
||||
{ "appendconfig", 1, &val, 'C' },
|
||||
#endif
|
||||
{ "mouse", 1, NULL, 'm' },
|
||||
{ "nodevice", 1, NULL, 'N' },
|
||||
@ -1048,6 +1051,10 @@ static void parse_input(int argc, char *argv[])
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'C':
|
||||
strlcpy(g_extern.append_config_path, optarg, sizeof(g_extern.append_config_path));
|
||||
break;
|
||||
|
||||
case 'B':
|
||||
strlcpy(g_extern.bps_name, optarg, sizeof(g_extern.bps_name));
|
||||
g_extern.bps_pref = true;
|
||||
|
13
settings.c
13
settings.c
@ -336,6 +336,19 @@ bool config_load_file(const char *path)
|
||||
if (conf == NULL)
|
||||
return true;
|
||||
|
||||
char *save;
|
||||
char tmp_append_path[PATH_MAX]; // Don't destroy append_config_path.
|
||||
strlcpy(tmp_append_path, g_extern.append_config_path, sizeof(tmp_append_path));
|
||||
const char *extra_path = strtok_r(tmp_append_path, ",", &save);
|
||||
while (extra_path)
|
||||
{
|
||||
RARCH_LOG("Appending config \"%s\"\n", extra_path);
|
||||
bool ret = config_append_file(conf, extra_path);
|
||||
if (!ret)
|
||||
RARCH_ERR("Failed to append config \"%s\"\n", extra_path);
|
||||
extra_path = strtok_r(NULL, ";", &save);
|
||||
}
|
||||
|
||||
if (g_extern.verbose)
|
||||
{
|
||||
fprintf(stderr, "=== Config ===\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user