From be81edad84f88f62babf4357ab8f1c1b22fcb10f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 29 Sep 2016 08:23:41 +0200 Subject: [PATCH] Create path_get --- command.c | 10 +++++----- configuration.c | 6 +++--- dynamic.c | 10 +++++----- gfx/common/win32_common.cpp | 2 +- paths.c | 22 ++++++++++++++-------- paths.h | 5 ++--- tasks/task_content.c | 10 +++++----- 7 files changed, 35 insertions(+), 30 deletions(-) diff --git a/command.c b/command.c index f80290a9ad..bbe42fc141 100644 --- a/command.c +++ b/command.c @@ -1499,7 +1499,7 @@ static bool command_event_save_core_config(void) } /* Infer file name based on libretro core. */ - if (!string_is_empty(path_get_core()) && path_file_exists(path_get_core())) + if (!string_is_empty(path_get(RARCH_PATH_CORE)) && path_file_exists(path_get(RARCH_PATH_CORE))) { unsigned i; RARCH_LOG("%s\n", msg_hash_to_str(MSG_USING_CORE_NAME_FOR_NEW_CONFIG)); @@ -1511,7 +1511,7 @@ static bool command_event_save_core_config(void) fill_pathname_base_noext( config_name, - path_get_core(), + path_get(RARCH_PATH_CORE), sizeof(config_name)); fill_pathname_join(config_path, config_dir, config_name, @@ -1842,14 +1842,14 @@ bool command_event(enum event_command cmd, void *data) core_info_ctx_find_t info_find; #if defined(HAVE_DYNAMIC) - if (string_is_empty(path_get_core())) + if (string_is_empty(path_get(RARCH_PATH_CORE))) return false; #endif libretro_get_system_info( - path_get_core(), + path_get(RARCH_PATH_CORE), system, ptr); - info_find.path = path_get_core(); + info_find.path = path_get(RARCH_PATH_CORE); if (!core_info_load(&info_find)) { diff --git a/configuration.c b/configuration.c index 846864b6b2..bd3f03e7e8 100644 --- a/configuration.c +++ b/configuration.c @@ -2049,10 +2049,10 @@ static bool config_load_file(const char *path, bool set_defaults, } /* Safe-guard against older behavior. */ - if (path_is_directory(path_get_core())) + if (path_is_directory(path_get(RARCH_PATH_CORE))) { RARCH_WARN("\"libretro_path\" is a directory, using this for \"libretro_directory\" instead.\n"); - strlcpy(settings->directory.libretro, path_get_core(), + strlcpy(settings->directory.libretro, path_get(RARCH_PATH_CORE), sizeof(settings->directory.libretro)); path_clear_core(); } @@ -2283,7 +2283,7 @@ bool config_load_override(void) /* Store the libretro_path we're using since it will be * overwritten by the override when reloading. */ - strlcpy(buf, path_get_core(), sizeof(buf)); + strlcpy(buf, path_get(RARCH_PATH_CORE), sizeof(buf)); /* Toggle has_save_path to false so it resets */ retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); diff --git a/dynamic.c b/dynamic.c index 762067c7e9..5e102ab252 100644 --- a/dynamic.c +++ b/dynamic.c @@ -222,7 +222,7 @@ static void load_dynamic_core(void) retroarch_fail(1, "init_libretro_sym()"); } - if (string_is_empty(path_get_core())) + if (string_is_empty(path_get(RARCH_PATH_CORE))) { RARCH_ERR("RetroArch is built for dynamic libretro cores, but " "libretro_path is not set. Cannot continue.\n"); @@ -237,12 +237,12 @@ static void load_dynamic_core(void) path_get_core_size()); RARCH_LOG("Loading dynamic libretro core from: \"%s\"\n", - path_get_core()); - lib_handle = dylib_load(path_get_core()); + path_get(RARCH_PATH_CORE)); + lib_handle = dylib_load(path_get(RARCH_PATH_CORE)); if (!lib_handle) { RARCH_ERR("Failed to open libretro core: \"%s\"\n", - path_get_core()); + path_get(RARCH_PATH_CORE)); RARCH_ERR("Error(s): %s\n", dylib_error()); retroarch_fail(1, "load_dynamic()"); } @@ -1265,7 +1265,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) { const char **path = (const char**)data; #ifdef HAVE_DYNAMIC - *path = path_get_core(); + *path = path_get(RARCH_PATH_CORE); #else *path = NULL; #endif diff --git a/gfx/common/win32_common.cpp b/gfx/common/win32_common.cpp index 55090b3849..3abebcb945 100644 --- a/gfx/common/win32_common.cpp +++ b/gfx/common/win32_common.cpp @@ -302,7 +302,7 @@ static int win32_drag_query_file(HWND hwnd, WPARAM wparam) if(!string_is_equal(info->systemname, current_core->systemname)) break; - if(string_is_equal(path_get_core(), info->path)) + if(string_is_equal(path_get(RARCH_PATH_CORE), info->path)) { /* Our previous core supports the current rom */ content_ctx_info_t content_info = {0}; diff --git a/paths.c b/paths.c index b9cad1bb69..5bc130a462 100644 --- a/paths.c +++ b/paths.c @@ -318,7 +318,7 @@ static bool path_init_subsystem(void) info = libretro_find_subsystem_info( system->subsystem.data, system->subsystem.size, - path_get_subsystem()); + path_get(RARCH_PATH_SUBSYSTEM)); /* We'll handle this error gracefully later. */ @@ -468,11 +468,6 @@ void path_fill_names(void) /* Core file path */ -const char *path_get_subsystem(void) -{ - return subsystem_path; -} - const char *path_get_basename(void) { return path_main_basename; @@ -483,9 +478,20 @@ char *path_get_core_ptr(void) return path_libretro; } -const char *path_get_core(void) +const char *path_get(enum rarch_path_type type) { - return path_libretro; + switch (type) + { + case RARCH_PATH_SUBSYSTEM: + return subsystem_path; + case RARCH_PATH_CORE: + return path_libretro; + default: + case RARCH_PATH_NONE: + break; + } + + return NULL; } bool path_is_core_empty(void) diff --git a/paths.h b/paths.h index 842355df2d..42f437d23b 100644 --- a/paths.h +++ b/paths.h @@ -55,6 +55,7 @@ void path_fill_names(void); /* set functions */ + bool path_set(enum rarch_path_type type, const char *path); void path_set_redirect(void); @@ -79,7 +80,7 @@ struct string_list *path_get_subsystem_list(void); /* get functions */ -const char *path_get_subsystem(void); +const char *path_get(enum rarch_path_type type); bool path_get_content(char **fullpath); @@ -87,8 +88,6 @@ const char *path_get_current_savefile_dir(void); const char *path_get_basename(void); -const char *path_get_core(void); - const char *path_get_core_options(void); const char *path_get_config(void); diff --git a/tasks/task_content.c b/tasks/task_content.c index 292b417ec7..521090119b 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -601,13 +601,13 @@ static const struct retro_subsystem_info *init_content_file_subsystem(bool *ret) if (system) special = libretro_find_subsystem_info(system->subsystem.data, - system->subsystem.size, path_get_subsystem()); + system->subsystem.size, path_get(RARCH_PATH_SUBSYSTEM)); if (!special) { RARCH_ERR( "Failed to find subsystem \"%s\" in libretro implementation.\n", - path_get_subsystem()); + path_get(RARCH_PATH_SUBSYSTEM)); goto error; } @@ -848,8 +848,8 @@ static void menu_content_environment_get(int *argc, char *argv[], if (fullpath && *fullpath) wrap_args->content_path = fullpath; if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_LIBRETRO)) - wrap_args->libretro_path = string_is_empty(path_get_core()) ? NULL : - path_get_core(); + wrap_args->libretro_path = string_is_empty(path_get(RARCH_PATH_CORE)) ? NULL : + path_get(RARCH_PATH_CORE); } #endif @@ -952,7 +952,7 @@ static bool task_load_content(content_ctx_info_t *content_info, #endif break; default: - core_path = path_get_core(); + core_path = path_get(RARCH_PATH_CORE); core_name = info->library_name; break; }