From 1266c0609a1291205075cbd88c1a88ca9be40777 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 30 Sep 2016 04:43:16 +0200 Subject: [PATCH] Create path_is_empty --- command.c | 6 ++-- configuration.c | 8 ++--- file_path_special.c | 2 +- menu/cbs/menu_cbs_get_value.c | 2 +- menu/menu_shader.c | 2 +- paths.c | 65 ++++++++++++++++------------------- paths.h | 10 +----- retroarch.c | 4 +-- runloop.c | 4 +-- tasks/task_content.c | 6 ++-- 10 files changed, 47 insertions(+), 62 deletions(-) diff --git a/command.c b/command.c index a3ba86e9f2..cc4094c601 100644 --- a/command.c +++ b/command.c @@ -981,7 +981,7 @@ static bool command_event_disk_control_append_image(const char *path) command_event(CMD_EVENT_AUTOSAVE_DEINIT, NULL); /* TODO: Need to figure out what to do with subsystems case. */ - if (path_is_subsystem_empty()) + if (path_is_empty(RARCH_PATH_SUBSYSTEM)) { /* Update paths for our new image. * If we actually use append_image, we assume that we @@ -1485,7 +1485,7 @@ static bool command_event_save_core_config(void) if (!string_is_empty(settings->directory.menu_config)) strlcpy(config_dir, settings->directory.menu_config, sizeof(config_dir)); - else if (!path_is_config_empty()) /* Fallback */ + else if (!path_is_empty(RARCH_PATH_CONFIG)) /* Fallback */ fill_pathname_basedir(config_dir, path_get(RARCH_PATH_CONFIG), sizeof(config_dir)); else @@ -1591,7 +1591,7 @@ static void command_event_save_current_config(int override_type) RARCH_ERR("[overrides] %s\n", msg); } } - else if (!path_is_config_empty()) + else if (!path_is_empty(RARCH_PATH_CONFIG)) command_event_save_config(path_get(RARCH_PATH_CONFIG), msg, sizeof(msg)); if (!string_is_empty(msg)) diff --git a/configuration.c b/configuration.c index 65a7c465c2..b7eff22ad3 100644 --- a/configuration.c +++ b/configuration.c @@ -1716,7 +1716,7 @@ static bool config_load_file(const char *path, bool set_defaults, if (set_defaults) config_set_defaults(); - if (!path_is_config_append_empty()) + if (!path_is_empty(RARCH_PATH_CONFIG_APPEND)) { /* Don't destroy append_config_path, store in temporary * variable. */ @@ -2573,14 +2573,14 @@ bool config_load_shader_preset(void) static void parse_config_file(void) { - if (!path_is_config_empty()) + if (!path_is_empty(RARCH_PATH_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()) + if (!path_is_empty(RARCH_PATH_CONFIG)) RARCH_LOG("Config: found default config: %s.\n", path_get(RARCH_PATH_CONFIG)); } @@ -3260,7 +3260,7 @@ bool config_replace(char *path) if (string_is_equal(path, path_get(RARCH_PATH_CONFIG))) return false; - if (settings->config_save_on_exit && !path_is_config_empty()) + if (settings->config_save_on_exit && !path_is_empty(RARCH_PATH_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 cd1ec4fb76..bb78f66241 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -290,7 +290,7 @@ void fill_pathname_application_special(char *s, size_t len, enum application_spe * fallback to the location of the current configuration file. */ if (!string_is_empty(settings->directory.menu_config)) strlcpy(s, settings->directory.menu_config, len); - else if (!path_is_config_empty()) + else if (!path_is_empty(RARCH_PATH_CONFIG)) fill_pathname_basedir(s, path_get(RARCH_PATH_CONFIG), len); } break; diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 974b407e0c..47a6c5ed18 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -130,7 +130,7 @@ static void menu_action_setting_disp_set_label_configurations( *w = 19; strlcpy(s2, path, len2); - if (!path_is_config_empty()) + if (!path_is_empty(RARCH_PATH_CONFIG)) fill_pathname_base(s, path_get(RARCH_PATH_CONFIG), len); else diff --git a/menu/menu_shader.c b/menu/menu_shader.c index f165d1e100..68cea2f5be 100644 --- a/menu/menu_shader.c +++ b/menu/menu_shader.c @@ -295,7 +295,7 @@ bool menu_shader_manager_save_preset( strlcpy(buffer, conf_path, sizeof(buffer)); } - if (!path_is_config_empty()) + if (!path_is_empty(RARCH_PATH_CONFIG)) fill_pathname_basedir( config_directory, path_get(RARCH_PATH_CONFIG), diff --git a/paths.c b/paths.c index 5f45e1f6c7..caa0239f0c 100644 --- a/paths.c +++ b/paths.c @@ -310,7 +310,7 @@ static bool path_init_subsystem(void) if (!system) return false; - if (path_is_subsystem_empty()) + if (path_is_empty(RARCH_PATH_SUBSYSTEM)) return false; /* For subsystems, we know exactly which RAM types are supported. */ @@ -325,7 +325,7 @@ static bool path_init_subsystem(void) if (info) { unsigned num_content = MIN(info->num_roms, - path_is_subsystem_empty() ? + path_is_empty(RARCH_PATH_SUBSYSTEM) ? 0 : subsystem_fullpaths->size); for (i = 0; i < num_content; i++) @@ -469,17 +469,17 @@ const char *path_get(enum rarch_path_type type) case RARCH_PATH_BASENAME: return path_main_basename; case RARCH_PATH_CORE_OPTIONS: - if (!path_is_core_options_empty()) + if (!path_is_empty(RARCH_PATH_CORE_OPTIONS)) return path_core_options_file; break; case RARCH_PATH_SUBSYSTEM: return subsystem_path; case RARCH_PATH_CONFIG: - if (!path_is_config_empty()) + if (!path_is_empty(RARCH_PATH_CONFIG)) return path_config_file; break; case RARCH_PATH_CONFIG_APPEND: - if (!path_is_config_append_empty()) + if (!path_is_empty(RARCH_PATH_CONFIG_APPEND)) return path_config_append_file; break; case RARCH_PATH_CORE: @@ -492,10 +492,6 @@ const char *path_get(enum rarch_path_type type) return NULL; } -bool path_is_core_empty(void) -{ - return !path_libretro[0]; -} size_t path_get_core_size(void) { @@ -571,20 +567,31 @@ bool path_set(enum rarch_path_type type, const char *path) return true; } -/* Config file path */ - -bool path_is_subsystem_empty(void) +bool path_is_empty(enum rarch_path_type type) { - if (string_is_empty(subsystem_path)) - return true; - - return false; -} - -bool path_is_config_empty(void) -{ - if (string_is_empty(path_config_file)) - return true; + switch (type) + { + case RARCH_PATH_SUBSYSTEM: + if (string_is_empty(subsystem_path)) + return true; + break; + case RARCH_PATH_CONFIG: + if (string_is_empty(path_config_file)) + return true; + break; + case RARCH_PATH_CORE_OPTIONS: + if (string_is_empty(path_core_options_file)) + return true; + break; + case RARCH_PATH_CONFIG_APPEND: + if (string_is_empty(path_config_append_file)) + return true; + break; + case RARCH_PATH_CORE: + return !path_libretro[0]; + default: + break; + } return false; } @@ -640,23 +647,9 @@ void path_clear_all(void) /* Core options file path */ -bool path_is_core_options_empty(void) -{ - if (string_is_empty(path_core_options_file)) - return true; - - return false; -} /* Append config file path */ -bool path_is_config_append_empty(void) -{ - if (string_is_empty(path_config_append_file)) - return true; - - return false; -} bool path_get_content(char **fullpath) { diff --git a/paths.h b/paths.h index 0e56f32724..83043be421 100644 --- a/paths.h +++ b/paths.h @@ -96,15 +96,7 @@ void path_clear_all(void); /* is functions */ -bool path_is_subsystem_empty(void); - -bool path_is_core_empty(void); - -bool path_is_config_empty(void); - -bool path_is_core_options_empty(void); - -bool path_is_config_append_empty(void); +bool path_is_empty(enum rarch_path_type type); enum rarch_content_type path_is_media_type(const char *path); diff --git a/retroarch.c b/retroarch.c index 0c91cd5982..6b4aef58ad 100644 --- a/retroarch.c +++ b/retroarch.c @@ -839,13 +839,13 @@ static void retroarch_parse_input(int argc, char *argv[]) #endif } - if (path_is_subsystem_empty() && optind < argc) + if (path_is_empty(RARCH_PATH_SUBSYSTEM) && optind < argc) { /* We requested explicit ROM, so use PLAIN core type. */ retroarch_set_current_core_type(CORE_TYPE_PLAIN, false); path_set(RARCH_PATH_NAMES, (const char*)argv[optind]); } - else if (!path_is_subsystem_empty() && optind < argc) + else if (!path_is_empty(RARCH_PATH_SUBSYSTEM) && optind < argc) { /* We requested explicit ROM, so use PLAIN core type. */ retroarch_set_current_core_type(CORE_TYPE_PLAIN, false); diff --git a/runloop.c b/runloop.c index efed85c129..cdf2fe2e11 100644 --- a/runloop.c +++ b/runloop.c @@ -940,7 +940,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) if (settings) options_path = settings->path.core_options; - if (options_path && string_is_empty(options_path) && !path_is_config_empty()) + if (options_path && string_is_empty(options_path) && !path_is_empty(RARCH_PATH_CONFIG)) { fill_pathname_resolve_relative(buf, path_get(RARCH_PATH_CONFIG), file_path_str(FILE_PATH_CORE_OPTIONS_CONFIG), sizeof(buf)); @@ -966,7 +966,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) /* check if game options file was just created and flush to that file instead */ - if(!path_is_core_options_empty()) + if(!path_is_empty(RARCH_PATH_CORE_OPTIONS)) { core_option_manager_flush_game_specific(runloop_core_options, path_get(RARCH_PATH_CORE_OPTIONS)); diff --git a/tasks/task_content.c b/tasks/task_content.c index c313882269..5f8866b3af 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -590,7 +590,7 @@ static const struct retro_subsystem_info *init_content_file_subsystem(bool *ret) rarch_system_info_t *system = NULL; struct string_list *subsystem = path_get_subsystem_list(); - if (path_is_subsystem_empty()) + if (path_is_empty(RARCH_PATH_SUBSYSTEM)) { *ret = true; return NULL; @@ -653,7 +653,7 @@ static bool init_content_file_set_attribs( attr.i = 0; - if (!path_is_subsystem_empty() && special) + if (!path_is_empty(RARCH_PATH_SUBSYSTEM) && special) { unsigned i; @@ -845,7 +845,7 @@ static void menu_content_environment_get(int *argc, char *argv[], wrap_args->state_path = NULL; wrap_args->content_path = NULL; - if (!path_is_config_empty()) + if (!path_is_empty(RARCH_PATH_CONFIG)) wrap_args->config_path = path_get(RARCH_PATH_CONFIG); if (!dir_is_savefile_empty()) wrap_args->sram_path = dir_get_savefile();