(configuration.c) Refactor config_load_overrides

This commit is contained in:
twinaphex 2015-11-21 18:21:53 +01:00
parent 5c71cb06d4
commit df0ea1c01d

View File

@ -1821,6 +1821,7 @@ static void config_load_core_specific(void)
*/ */
bool config_load_override(void) bool config_load_override(void)
{ {
char buf[PATH_MAX_LENGTH] = {0};
char config_directory[PATH_MAX_LENGTH] = {0}; /* path to the directory containing retroarch.cfg (prefix) */ char config_directory[PATH_MAX_LENGTH] = {0}; /* path to the directory containing retroarch.cfg (prefix) */
char core_path[PATH_MAX_LENGTH] = {0}; /* final path for core-specific configuration (prefix+suffix) */ char core_path[PATH_MAX_LENGTH] = {0}; /* final path for core-specific configuration (prefix+suffix) */
char game_path[PATH_MAX_LENGTH] = {0}; /* final path for game-specific configuration (prefix+suffix) */ char game_path[PATH_MAX_LENGTH] = {0}; /* final path for game-specific configuration (prefix+suffix) */
@ -1847,7 +1848,7 @@ bool config_load_override(void)
if (!core_name || !game_name) if (!core_name || !game_name)
return false; return false;
if (core_name[0] == '\0' || game_name == '\0') if (core_name[0] == '\0' || game_name[0] == '\0')
return false; return false;
RARCH_LOG("Overrides: core name: %s\n", core_name); RARCH_LOG("Overrides: core name: %s\n", core_name);
@ -1898,7 +1899,6 @@ bool config_load_override(void)
else else
RARCH_LOG("Overrides: no core-specific overrides found at %s\n", core_path); RARCH_LOG("Overrides: no core-specific overrides found at %s\n", core_path);
/* Create a new config file from game_path */ /* Create a new config file from game_path */
new_conf = config_file_new(game_path); new_conf = config_file_new(game_path);
@ -1921,10 +1921,10 @@ bool config_load_override(void)
else else
RARCH_LOG("Overrides: no game-specific overrides found at %s\n", game_path); RARCH_LOG("Overrides: no game-specific overrides found at %s\n", game_path);
if (!should_append)
return false;
/* Re-load the configuration with any overrides that might have been found */ /* Re-load the configuration with any overrides that might have been found */
if (should_append)
{
char buf[PATH_MAX_LENGTH] = {0};
if (settings->core_specific_config) if (settings->core_specific_config)
{ {
@ -1947,8 +1947,9 @@ bool config_load_override(void)
global->has_set.save_path = false; global->has_set.save_path = false;
global->has_set.state_path = false; global->has_set.state_path = false;
if (config_load_file(global->path.config, false)) if (!config_load_file(global->path.config, false))
{ return false;
/* Restore the libretro_path we're using /* Restore the libretro_path we're using
* since it will be overwritten by the override when reloading. */ * since it will be overwritten by the override when reloading. */
strlcpy(settings->libretro,buf,sizeof(settings->libretro)); strlcpy(settings->libretro,buf,sizeof(settings->libretro));
@ -1959,10 +1960,6 @@ bool config_load_override(void)
global->has_set.state_path = true; global->has_set.state_path = true;
return true; return true;
} }
}
return false;
}
/** /**
* config_unload_override: * config_unload_override: