mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 22:14:17 +00:00
Refactor append config code
This commit is contained in:
parent
0254d8714d
commit
ef02fb8a96
@ -1642,9 +1642,7 @@ static bool config_load_file(const char *path, bool set_defaults,
|
|||||||
unsigned i;
|
unsigned i;
|
||||||
bool tmp_bool = false;
|
bool tmp_bool = false;
|
||||||
char *save = NULL;
|
char *save = NULL;
|
||||||
const char *extra_path = NULL;
|
|
||||||
char tmp_str[PATH_MAX_LENGTH] = {0};
|
char tmp_str[PATH_MAX_LENGTH] = {0};
|
||||||
char tmp_append_path[PATH_MAX_LENGTH] = {0}; /* Don't destroy append_config_path. */
|
|
||||||
unsigned msg_color = 0;
|
unsigned msg_color = 0;
|
||||||
config_file_t *conf = NULL;
|
config_file_t *conf = NULL;
|
||||||
struct config_int_setting *int_settings = NULL;
|
struct config_int_setting *int_settings = NULL;
|
||||||
@ -1678,20 +1676,29 @@ static bool config_load_file(const char *path, bool set_defaults,
|
|||||||
if (set_defaults)
|
if (set_defaults)
|
||||||
config_set_defaults();
|
config_set_defaults();
|
||||||
|
|
||||||
strlcpy(tmp_append_path, global->path.append_config,
|
if (!path_is_config_append_empty())
|
||||||
sizeof(tmp_append_path));
|
|
||||||
extra_path = strtok_r(tmp_append_path, "|", &save);
|
|
||||||
|
|
||||||
while (extra_path)
|
|
||||||
{
|
{
|
||||||
bool ret = config_append_file(conf, extra_path);
|
/* Don't destroy append_config_path, store in temporary
|
||||||
|
* variable. */
|
||||||
|
char tmp_append_path[PATH_MAX_LENGTH] = {0};
|
||||||
|
const char *extra_path = NULL;
|
||||||
|
|
||||||
RARCH_LOG("Config: appending config \"%s\"\n", extra_path);
|
strlcpy(tmp_append_path, path_get_config_append(),
|
||||||
|
sizeof(tmp_append_path));
|
||||||
|
extra_path = strtok_r(tmp_append_path, "|", &save);
|
||||||
|
|
||||||
if (!ret)
|
while (extra_path)
|
||||||
RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path);
|
{
|
||||||
extra_path = strtok_r(NULL, "|", &save);
|
bool ret = config_append_file(conf, extra_path);
|
||||||
|
|
||||||
|
RARCH_LOG("Config: appending config \"%s\"\n", extra_path);
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
RARCH_ERR("Config: failed to append config \"%s\"\n", extra_path);
|
||||||
|
extra_path = strtok_r(NULL, "|", &save);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (verbosity_is_enabled())
|
if (verbosity_is_enabled())
|
||||||
{
|
{
|
||||||
@ -1719,6 +1726,7 @@ static bool config_load_file(const char *path, bool set_defaults,
|
|||||||
if (config_get_bool(conf, bool_settings[i].ident, &tmp))
|
if (config_get_bool(conf, bool_settings[i].ident, &tmp))
|
||||||
*bool_settings[i].ptr = tmp;
|
*bool_settings[i].ptr = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rarch_ctl(RARCH_CTL_IS_FORCE_FULLSCREEN, NULL))
|
if (!rarch_ctl(RARCH_CTL_IS_FORCE_FULLSCREEN, NULL))
|
||||||
CONFIG_GET_BOOL_BASE(conf, settings, video.fullscreen, "video_fullscreen");
|
CONFIG_GET_BOOL_BASE(conf, settings, video.fullscreen, "video_fullscreen");
|
||||||
|
|
||||||
@ -2171,10 +2179,10 @@ bool config_load_override(void)
|
|||||||
/* If a core override exists, add its location to append_config_path */
|
/* If a core override exists, add its location to append_config_path */
|
||||||
if (new_conf)
|
if (new_conf)
|
||||||
{
|
{
|
||||||
config_file_free(new_conf);
|
|
||||||
|
|
||||||
RARCH_LOG("[overrides] core-specific overrides found at %s.\n", core_path);
|
RARCH_LOG("[overrides] core-specific overrides found at %s.\n", core_path);
|
||||||
strlcpy(global->path.append_config, core_path, sizeof(global->path.append_config));
|
|
||||||
|
config_file_free(new_conf);
|
||||||
|
path_set_config_append(core_path);
|
||||||
|
|
||||||
should_append = true;
|
should_append = true;
|
||||||
}
|
}
|
||||||
@ -2187,16 +2195,22 @@ bool config_load_override(void)
|
|||||||
/* If a game override exists, add it's location to append_config_path */
|
/* If a game override exists, add it's location to append_config_path */
|
||||||
if (new_conf)
|
if (new_conf)
|
||||||
{
|
{
|
||||||
|
char temp_path[PATH_MAX_LENGTH] = {0};
|
||||||
|
|
||||||
config_file_free(new_conf);
|
config_file_free(new_conf);
|
||||||
|
|
||||||
RARCH_LOG("[overrides] game-specific overrides found at %s.\n", game_path);
|
RARCH_LOG("[overrides] game-specific overrides found at %s.\n", game_path);
|
||||||
|
|
||||||
if (should_append)
|
if (should_append)
|
||||||
{
|
{
|
||||||
strlcat(global->path.append_config, "|", sizeof(global->path.append_config));
|
strlcpy(temp_path, path_get_config_append(), sizeof(temp_path));
|
||||||
strlcat(global->path.append_config, game_path, sizeof(global->path.append_config));
|
strlcat(temp_path, "|", sizeof(temp_path));
|
||||||
|
strlcat(temp_path, game_path, sizeof(temp_path));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
strlcpy(global->path.append_config, game_path, sizeof(global->path.append_config));
|
strlcpy(temp_path, game_path, sizeof(temp_path));
|
||||||
|
|
||||||
|
path_set_config_append(temp_path);
|
||||||
|
|
||||||
should_append = true;
|
should_append = true;
|
||||||
}
|
}
|
||||||
@ -2234,7 +2248,9 @@ bool config_load_override(void)
|
|||||||
/* Reset save paths. */
|
/* Reset save paths. */
|
||||||
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH);
|
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH);
|
||||||
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH);
|
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH);
|
||||||
global->path.append_config[0] = '\0';
|
|
||||||
|
path_clear_config_append();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2248,12 +2264,7 @@ bool config_load_override(void)
|
|||||||
*/
|
*/
|
||||||
bool config_unload_override(void)
|
bool config_unload_override(void)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
path_clear_config_append();
|
||||||
|
|
||||||
if (!global)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
*global->path.append_config = '\0';
|
|
||||||
|
|
||||||
/* Toggle has_save_path to false so it resets */
|
/* Toggle has_save_path to false so it resets */
|
||||||
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH);
|
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH);
|
||||||
|
5
paths.c
5
paths.c
@ -537,14 +537,9 @@ const char *path_get_config_append(void)
|
|||||||
|
|
||||||
void path_clear_all(void)
|
void path_clear_all(void)
|
||||||
{
|
{
|
||||||
global_t *global = global_get_ptr();
|
|
||||||
|
|
||||||
path_clear_config();
|
path_clear_config();
|
||||||
path_clear_config_append();
|
path_clear_config_append();
|
||||||
path_clear_core_options();
|
path_clear_core_options();
|
||||||
|
|
||||||
if (global)
|
|
||||||
memset(&global->path, 0, sizeof(struct rarch_path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum rarch_content_type path_is_media_type(const char *path)
|
enum rarch_content_type path_is_media_type(const char *path)
|
||||||
|
@ -728,8 +728,7 @@ static void retroarch_parse_input(int argc, char *argv[])
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
case RA_OPT_APPENDCONFIG:
|
case RA_OPT_APPENDCONFIG:
|
||||||
strlcpy(global->path.append_config, optarg,
|
path_set_config_append(optarg);
|
||||||
sizeof(global->path.append_config));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RA_OPT_SIZE:
|
case RA_OPT_SIZE:
|
||||||
|
@ -151,12 +151,6 @@ typedef struct rarch_dir
|
|||||||
#endif
|
#endif
|
||||||
} rarch_dir_t;
|
} rarch_dir_t;
|
||||||
|
|
||||||
typedef struct rarch_path
|
|
||||||
{
|
|
||||||
/* Config associated with global "default" config. */
|
|
||||||
char append_config[PATH_MAX_LENGTH];
|
|
||||||
} rarch_path_t;
|
|
||||||
|
|
||||||
typedef struct rarch_resolution
|
typedef struct rarch_resolution
|
||||||
{
|
{
|
||||||
unsigned idx;
|
unsigned idx;
|
||||||
@ -167,7 +161,6 @@ typedef struct rarch_resolution
|
|||||||
|
|
||||||
typedef struct global
|
typedef struct global
|
||||||
{
|
{
|
||||||
rarch_path_t path;
|
|
||||||
rarch_dir_t dir;
|
rarch_dir_t dir;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
|
Loading…
x
Reference in New Issue
Block a user