From 329f6ad612f6ea6904a1f43f79ee5602a9caaff3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 29 Sep 2016 08:31:41 +0200 Subject: [PATCH] Update path_get --- command.c | 8 ++++---- configuration.c | 30 +++++++++++++++--------------- file_path_special.c | 2 +- menu/cbs/menu_cbs_get_value.c | 2 +- menu/menu_shader.c | 4 ++-- paths.c | 22 ++++++++-------------- paths.h | 4 ---- runloop.c | 2 +- tasks/task_content.c | 2 +- 9 files changed, 33 insertions(+), 43 deletions(-) diff --git a/command.c b/command.c index bbe42fc141..ae6e100855 100644 --- a/command.c +++ b/command.c @@ -1453,14 +1453,14 @@ static bool command_event_save_config(const char *config_path, { snprintf(s, len, "%s \"%s\".", msg_hash_to_str(MSG_SAVED_NEW_CONFIG_TO), - path_get_config()); + path_get(RARCH_PATH_CONFIG)); RARCH_LOG("%s\n", s); return true; } snprintf(s, len, "%s \"%s\".", msg_hash_to_str(MSG_FAILED_SAVING_CONFIG_TO), - path_get_config()); + path_get(RARCH_PATH_CONFIG)); RARCH_ERR("%s\n", s); return false; @@ -1489,7 +1489,7 @@ static bool command_event_save_core_config(void) strlcpy(config_dir, settings->directory.menu_config, sizeof(config_dir)); else if (!path_is_config_empty()) /* Fallback */ - fill_pathname_basedir(config_dir, path_get_config(), + fill_pathname_basedir(config_dir, path_get(RARCH_PATH_CONFIG), sizeof(config_dir)); else { @@ -1595,7 +1595,7 @@ static void command_event_save_current_config(int override_type) } } else if (!path_is_config_empty()) - command_event_save_config(path_get_config(), msg, sizeof(msg)); + command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg)); if (!string_is_empty(msg)) runloop_msg_queue_push(msg, 1, 180, true); diff --git a/configuration.c b/configuration.c index bd3f03e7e8..9dd127e048 100644 --- a/configuration.c +++ b/configuration.c @@ -1723,7 +1723,7 @@ static bool config_load_file(const char *path, bool set_defaults, char tmp_append_path[PATH_MAX_LENGTH] = {0}; const char *extra_path = NULL; - strlcpy(tmp_append_path, path_get_config_append(), + strlcpy(tmp_append_path, path_get(RARCH_PATH_CONFIG_APPEND), sizeof(tmp_append_path)); extra_path = strtok_r(tmp_append_path, "|", &save); @@ -1966,7 +1966,7 @@ static bool config_load_file(const char *path, bool set_defaults, { fill_pathname_resolve_relative( settings->path.content_history, - path_get_config(), + path_get(RARCH_PATH_CONFIG), file_path_str(FILE_PATH_CONTENT_HISTORY), sizeof(settings->path.content_history)); } @@ -1985,7 +1985,7 @@ static bool config_load_file(const char *path, bool set_defaults, { fill_pathname_resolve_relative( settings->path.content_music_history, - path_get_config(), + path_get(RARCH_PATH_CONFIG), file_path_str(FILE_PATH_CONTENT_MUSIC_HISTORY), sizeof(settings->path.content_music_history)); } @@ -2004,7 +2004,7 @@ static bool config_load_file(const char *path, bool set_defaults, { fill_pathname_resolve_relative( settings->path.content_video_history, - path_get_config(), + path_get(RARCH_PATH_CONFIG), file_path_str(FILE_PATH_CONTENT_VIDEO_HISTORY), sizeof(settings->path.content_video_history)); } @@ -2023,7 +2023,7 @@ static bool config_load_file(const char *path, bool set_defaults, { fill_pathname_resolve_relative( settings->path.content_image_history, - path_get_config(), + path_get(RARCH_PATH_CONFIG), file_path_str(FILE_PATH_CONTENT_IMAGE_HISTORY), sizeof(settings->path.content_image_history)); } @@ -2255,7 +2255,7 @@ bool config_load_override(void) if (should_append) { - strlcpy(temp_path, path_get_config_append(), sizeof(temp_path)); + strlcpy(temp_path, path_get(RARCH_PATH_CONFIG_APPEND), sizeof(temp_path)); strlcat(temp_path, "|", sizeof(temp_path)); strlcat(temp_path, game_path, sizeof(temp_path)); } @@ -2289,7 +2289,7 @@ bool config_load_override(void) retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH); - if (!config_load_file(path_get_config(), false, config_get_ptr())) + if (!config_load_file(path_get(RARCH_PATH_CONFIG), false, config_get_ptr())) return false; /* Restore the libretro_path we're using @@ -2322,7 +2322,7 @@ bool config_unload_override(void) retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH); retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_SAVE_PATH); - if (config_load_file(path_get_config(), false, config_get_ptr())) + if (config_load_file(path_get(RARCH_PATH_CONFIG), false, config_get_ptr())) { RARCH_LOG("[overrides] configuration overrides unloaded, original configuration restored.\n"); @@ -2575,19 +2575,19 @@ static void parse_config_file(void) { if (!path_is_config_empty()) { - RARCH_LOG("Config: loading config from: %s.\n", path_get_config()); + RARCH_LOG("Config: loading config from: %s.\n", path_get(RARCH_PATH_CONFIG)); } else { RARCH_LOG("Loading default config.\n"); if (!path_is_config_empty()) - RARCH_LOG("Config: found default config: %s.\n", path_get_config()); + RARCH_LOG("Config: found default config: %s.\n", path_get(RARCH_PATH_CONFIG)); } - if (config_load_file(path_get_config(), false, config_get_ptr())) + if (config_load_file(path_get(RARCH_PATH_CONFIG), false, config_get_ptr())) return; - RARCH_ERR("Config: couldn't find config at path: \"%s\"\n", path_get_config()); + RARCH_ERR("Config: couldn't find config at path: \"%s\"\n", path_get(RARCH_PATH_CONFIG)); } @@ -3118,7 +3118,7 @@ bool config_save_overrides(int override_type) conf = config_file_new(NULL); /* Load the original config file in memory */ - config_load_file(path_get_config(), false, settings); + config_load_file(path_get(RARCH_PATH_CONFIG), false, settings); bool_settings_size = populate_settings_bool(settings, &bool_settings); populate_settings_bool (overrides, &bool_overrides); @@ -3257,11 +3257,11 @@ bool config_replace(char *path) /* If config file to be replaced is the same as the * current config file, exit. */ - if (string_is_equal(path, path_get_config())) + if (string_is_equal(path, path_get(RARCH_PATH_CONFIG))) return false; if (settings->config_save_on_exit && !path_is_config_empty()) - config_save_file(path_get_config()); + config_save_file(path_get(RARCH_PATH_CONFIG)); path_set(RARCH_PATH_CONFIG, path); diff --git a/file_path_special.c b/file_path_special.c index 3c094566ba..cd1ec4fb76 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -291,7 +291,7 @@ void fill_pathname_application_special(char *s, size_t len, enum application_spe if (!string_is_empty(settings->directory.menu_config)) strlcpy(s, settings->directory.menu_config, len); else if (!path_is_config_empty()) - fill_pathname_basedir(s, path_get_config(), len); + fill_pathname_basedir(s, path_get(RARCH_PATH_CONFIG), len); } break; case APPLICATION_SPECIAL_DIRECTORY_ASSETS_ZARCH_ICONS: diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 74675d5e4a..696cdb1343 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -131,7 +131,7 @@ static void menu_action_setting_disp_set_label_configurations( strlcpy(s2, path, len2); if (!path_is_config_empty()) - fill_pathname_base(s, path_get_config(), + fill_pathname_base(s, path_get(RARCH_PATH_CONFIG), len); else strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DIRECTORY_DEFAULT), len); diff --git a/menu/menu_shader.c b/menu/menu_shader.c index 96455461d3..f165d1e100 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -53,7 +53,7 @@ void menu_shader_manager_init(void) struct video_shader *shader = NULL; config_file_t *conf = NULL; settings_t *settings = config_get_ptr(); - const char *config_path = path_get_config(); + const char *config_path = path_get(RARCH_PATH_CONFIG); menu_driver_ctl(RARCH_MENU_CTL_SHADER_GET, &shader); @@ -298,7 +298,7 @@ bool menu_shader_manager_save_preset( if (!path_is_config_empty()) fill_pathname_basedir( config_directory, - path_get_config(), + path_get(RARCH_PATH_CONFIG), sizeof(config_directory)); if (!fullpath) diff --git a/paths.c b/paths.c index 71c0fc246a..2e7a3b11f9 100644 --- a/paths.c +++ b/paths.c @@ -484,6 +484,14 @@ const char *path_get(enum rarch_path_type type) { case RARCH_PATH_SUBSYSTEM: return subsystem_path; + case RARCH_PATH_CONFIG: + if (!path_is_config_empty()) + return path_config_file; + break; + case RARCH_PATH_CONFIG_APPEND: + if (!path_is_config_append_empty()) + return path_config_append_file; + break; case RARCH_PATH_CORE: return path_libretro; default: @@ -581,13 +589,6 @@ bool path_is_config_empty(void) } -const char *path_get_config(void) -{ - if (!path_is_config_empty()) - return path_config_file; - - return NULL; -} bool path_get_default_shader_preset(char **preset) { @@ -662,13 +663,6 @@ bool path_get_content(char **fullpath) return true; } -const char *path_get_config_append(void) -{ - if (!path_is_config_append_empty()) - return path_config_append_file; - - return NULL; -} void path_clear_all(void) { diff --git a/paths.h b/paths.h index 42f437d23b..6cdd8a931a 100644 --- a/paths.h +++ b/paths.h @@ -90,10 +90,6 @@ const char *path_get_basename(void); const char *path_get_core_options(void); -const char *path_get_config(void); - -const char *path_get_config_append(void); - bool path_get_default_shader_preset(char **preset); /* clear functions */ diff --git a/runloop.c b/runloop.c index 8e2da9db39..4cd549e785 100644 --- a/runloop.c +++ b/runloop.c @@ -944,7 +944,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) if (options_path && string_is_empty(options_path) && !path_is_config_empty()) { - fill_pathname_resolve_relative(buf, path_get_config(), + fill_pathname_resolve_relative(buf, path_get(RARCH_PATH_CONFIG), file_path_str(FILE_PATH_CORE_OPTIONS_CONFIG), sizeof(buf)); options_path = buf; } diff --git a/tasks/task_content.c b/tasks/task_content.c index 521090119b..505a0e9cd3 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -840,7 +840,7 @@ static void menu_content_environment_get(int *argc, char *argv[], wrap_args->content_path = NULL; if (!path_is_config_empty()) - wrap_args->config_path = path_get_config(); + wrap_args->config_path = path_get(RARCH_PATH_CONFIG); if (!dir_is_savefile_empty()) wrap_args->sram_path = dir_get_savefile(); if (!dir_is_savestate_empty())