From 7e1a61570a3bf859241bdd9e7d3dd34016425871 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 29 Sep 2016 07:46:21 +0200 Subject: [PATCH] Add more functionality to path_set --- configuration.c | 10 +++++----- paths.c | 33 +++++++++++++++++---------------- paths.h | 8 ++------ retroarch.c | 2 +- runloop.c | 8 +------- 5 files changed, 26 insertions(+), 35 deletions(-) diff --git a/configuration.c b/configuration.c index 1266ccffd7..b44fd2a36b 100644 --- a/configuration.c +++ b/configuration.c @@ -1342,7 +1342,7 @@ static void config_set_defaults(void) char temp_str[PATH_MAX_LENGTH]; fill_pathname_expand_special(temp_str, g_defaults.path.config, sizeof(temp_str)); - path_set_config(temp_str); + path_set(RARCH_PATH_CONFIG, temp_str); } /* Avoid reloading config on every content load */ @@ -1540,7 +1540,7 @@ static config_file_t *open_default_config_file(void) if (!conf) return NULL; - path_set_config(conf_path); + path_set(RARCH_PATH_CONFIG, conf_path); return conf; } @@ -1926,7 +1926,7 @@ static bool config_load_file(const char *path, bool set_defaults, #ifndef HAVE_DYNAMIC if (config_get_path(conf, "libretro_path", tmp_str, sizeof(tmp_str))) - path_set_core(tmp_str); + path_set(RARCH_PATH_CORE, tmp_str); #endif #ifdef RARCH_CONSOLE @@ -2294,7 +2294,7 @@ bool config_load_override(void) /* Restore the libretro_path we're using * since it will be overwritten by the override when reloading. */ - path_set_core(buf); + path_set(RARCH_PATH_CORE, buf); runloop_msg_queue_push("Configuration override loaded.", 1, 100, true); /* Reset save paths. */ @@ -3263,7 +3263,7 @@ bool config_replace(char *path) if (settings->config_save_on_exit && !path_is_config_empty()) config_save_file(path_get_config()); - path_set_config(path); + path_set(RARCH_PATH_CONFIG, path); rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); diff --git a/paths.c b/paths.c index 6803071766..a5a32f0522 100644 --- a/paths.c +++ b/paths.c @@ -251,14 +251,13 @@ struct string_list *path_get_subsystem_list(void) const char *path_get_current_savefile_dir(void) { - char *ret = current_savefile_dir; - /* try to infer the path in case it's still empty by calling path_set_redirect */ - if (string_is_empty(ret) && !content_does_not_need_content()) + if (string_is_empty(current_savefile_dir) + && !content_does_not_need_content()) path_set_redirect(); - return ret; + return current_savefile_dir; } void path_set_special(char **argv, unsigned num_content) @@ -497,11 +496,6 @@ size_t path_get_core_size(void) return sizeof(path_libretro); } -void path_set_core(const char *path) -{ - strlcpy(path_libretro, path, sizeof(path_libretro)); -} - bool path_set(enum rarch_path_type type, const char *path) { if (!path) @@ -509,14 +503,25 @@ bool path_set(enum rarch_path_type type, const char *path) switch (type) { + case RARCH_PATH_CORE: + strlcpy(path_libretro, path, + sizeof(path_libretro)); + break; + case RARCH_PATH_CONFIG: + strlcpy(path_config_file, path, + sizeof(path_config_file)); + break; case RARCH_PATH_SUBSYSTEM: - strlcpy(subsystem_path, path, sizeof(subsystem_path)); + strlcpy(subsystem_path, path, + sizeof(subsystem_path)); break; case RARCH_PATH_CORE_OPTIONS: - strlcpy(path_core_options_file, path, sizeof(path_core_options_file)); + strlcpy(path_core_options_file, path, + sizeof(path_core_options_file)); break; case RARCH_PATH_CONTENT: - strlcpy(path_content, path, sizeof(path_content)); + strlcpy(path_content, path, + sizeof(path_content)); break; default: case RARCH_PATH_NONE: @@ -559,10 +564,6 @@ bool path_is_config_empty(void) return false; } -void path_set_config(const char *path) -{ - strlcpy(path_config_file, path, sizeof(path_config_file)); -} const char *path_get_config(void) { diff --git a/paths.h b/paths.h index 19a6365452..de11ea859f 100644 --- a/paths.h +++ b/paths.h @@ -34,6 +34,8 @@ enum rarch_content_type enum rarch_path_type { RARCH_PATH_NONE = 0, + RARCH_PATH_CORE, + RARCH_PATH_CONFIG, RARCH_PATH_CONTENT, RARCH_PATH_CORE_OPTIONS, RARCH_PATH_SUBSYSTEM @@ -61,12 +63,6 @@ void path_set_special(char **argv, unsigned num_content); void path_set_basename(const char *path); -void path_set_core(const char *path); - -void path_set_core_options(const char *path); - -void path_set_config(const char *path); - void path_set_config_append(const char *path); bool path_set_default_shader_preset(const char *preset); diff --git a/retroarch.c b/retroarch.c index aa00193eb2..cc2fb6bf66 100644 --- a/retroarch.c +++ b/retroarch.c @@ -589,7 +589,7 @@ static void retroarch_parse_input(int argc, char *argv[]) break; case 'c': - path_set_config(optarg); + path_set(RARCH_PATH_CONFIG, optarg); break; case 'r': diff --git a/runloop.c b/runloop.c index ad8d425c77..8e2da9db39 100644 --- a/runloop.c +++ b/runloop.c @@ -708,13 +708,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) } break; case RUNLOOP_CTL_SET_LIBRETRO_PATH: - { - const char *fullpath = (const char*)data; - if (!fullpath) - return false; - path_set_core(fullpath); - } - break; + return path_set(RARCH_PATH_CORE, (const char*)data); case RUNLOOP_CTL_FRAME_TIME_FREE: memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback));