Create path_clear

This commit is contained in:
twinaphex 2016-09-30 04:31:19 +02:00
parent 1cf45d785f
commit 228886062b
8 changed files with 48 additions and 77 deletions

View File

@ -1408,7 +1408,7 @@ static void command_event_restore_default_shader_preset(void)
strlcpy(settings->path.shader, preset, sizeof(settings->path.shader));
}
path_clear_default_shader_preset();
path_clear(RARCH_PATH_DEFAULT_SHADER_PRESET);
}
static bool command_event_save_auto_state(void)

View File

@ -2054,7 +2054,7 @@ static bool config_load_file(const char *path, bool set_defaults,
RARCH_WARN("\"libretro_path\" is a directory, using this for \"libretro_directory\" instead.\n");
strlcpy(settings->directory.libretro, path_get(RARCH_PATH_CORE),
sizeof(settings->directory.libretro));
path_clear_core();
path_clear(RARCH_PATH_CORE);
}
if (string_is_equal(settings->path.menu_wallpaper, "default"))
@ -2301,7 +2301,7 @@ bool config_load_override(void)
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_STATE_PATH);
retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_SAVE_PATH);
path_clear_config_append();
path_clear(RARCH_PATH_CONFIG_APPEND);
return true;
}
@ -2316,7 +2316,7 @@ bool config_load_override(void)
*/
bool config_unload_override(void)
{
path_clear_config_append();
path_clear(RARCH_PATH_CONFIG_APPEND);
/* Toggle has_save_path to false so it resets */
retroarch_override_setting_unset(RARCH_OVERRIDE_SETTING_STATE_PATH);
@ -3268,7 +3268,7 @@ bool config_replace(char *path)
rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL);
/* Load core in new config. */
path_clear_core();
path_clear(RARCH_PATH_CORE);
if (!task_push_content_load_default(
NULL, NULL,

85
paths.c
View File

@ -571,21 +571,6 @@ bool path_set(enum rarch_path_type type, const char *path)
return true;
}
void path_clear_subsystem(void)
{
*subsystem_path = '\0';
}
void path_clear_core(void)
{
*path_libretro = '\0';
}
void path_clear_default_shader_preset(void)
{
*path_default_shader_preset = '\0';
}
/* Config file path */
bool path_is_subsystem_empty(void)
@ -604,8 +589,6 @@ bool path_is_config_empty(void)
return false;
}
bool path_get_default_shader_preset(char **preset)
{
if (!preset)
@ -614,14 +597,45 @@ bool path_get_default_shader_preset(char **preset)
return true;
}
void path_clear_config(void)
void path_clear(enum rarch_path_type type)
{
*path_config_file = '\0';
switch (type)
{
case RARCH_PATH_SUBSYSTEM:
*subsystem_path = '\0';
break;
case RARCH_PATH_CORE:
*path_libretro = '\0';
break;
case RARCH_PATH_CONFIG:
*path_config_file = '\0';
break;
case RARCH_PATH_CONTENT:
*path_content = '\0';
break;
case RARCH_PATH_BASENAME:
*path_main_basename = '\0';
break;
case RARCH_PATH_CORE_OPTIONS:
*path_core_options_file = '\0';
break;
case RARCH_PATH_DEFAULT_SHADER_PRESET:
*path_default_shader_preset = '\0';
break;
case RARCH_PATH_CONFIG_APPEND:
*path_config_append_file = '\0';
break;
default:
break;
}
}
void path_clear_basename(void)
void path_clear_all(void)
{
*path_main_basename = '\0';
path_clear(RARCH_PATH_CONFIG);
path_clear(RARCH_PATH_CONFIG_APPEND);
path_clear(RARCH_PATH_CORE_OPTIONS);
path_clear(RARCH_PATH_BASENAME);
}
/* Core options file path */
@ -634,14 +648,6 @@ bool path_is_core_options_empty(void)
return false;
}
void path_clear_core_options(void)
{
*path_core_options_file = '\0';
}
/* Append config file path */
bool path_is_config_append_empty(void)
@ -652,17 +658,6 @@ bool path_is_config_append_empty(void)
return false;
}
void path_clear_config_append(void)
{
*path_config_append_file = '\0';
}
void path_clear_content(void)
{
*path_content = '\0';
}
bool path_get_content(char **fullpath)
{
if (!fullpath)
@ -672,16 +667,6 @@ bool path_get_content(char **fullpath)
return true;
}
void path_clear_all(void)
{
path_clear_config();
path_clear_config_append();
path_clear_core_options();
path_clear_basename();
}
enum rarch_content_type path_is_media_type(const char *path)
{
char ext_lower[PATH_MAX_LENGTH] = {0};

16
paths.h
View File

@ -90,21 +90,7 @@ bool path_get_default_shader_preset(char **preset);
/* clear functions */
void path_clear_subsystem(void);
void path_clear_default_shader_preset(void);
void path_clear_basename(void);
void path_clear_content(void);
void path_clear_core(void);
void path_clear_config(void);
void path_clear_core_options(void);
void path_clear_config_append(void);
void path_clear(enum rarch_path_type type);
void path_clear_all(void);

View File

@ -469,7 +469,7 @@ static void retroarch_parse_input(int argc, char *argv[])
if (!current_core_explicitly_set)
retroarch_set_current_core_type(CORE_TYPE_DUMMY, false);
path_clear_subsystem();
path_clear(RARCH_PATH_SUBSYSTEM);
retroarch_override_setting_free_state();
@ -608,7 +608,7 @@ static void retroarch_parse_input(int argc, char *argv[])
case 'L':
if (path_is_directory(optarg))
{
path_clear_core();
path_clear(RARCH_PATH_CORE);
strlcpy(settings->directory.libretro, optarg,
sizeof(settings->directory.libretro));

View File

@ -743,7 +743,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
rarch_ctl(RARCH_CTL_UNSET_IPS_PREF, NULL);
rarch_ctl(RARCH_CTL_UNSET_UPS_PREF, NULL);
rarch_ctl(RARCH_CTL_UNSET_PATCH_BLOCKED, NULL);
path_clear_content();
path_clear(RARCH_PATH_CONTENT);
runloop_overrides_active = false;
core_unset_input_descriptors();
@ -970,7 +970,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
{
core_option_manager_flush_game_specific(runloop_core_options,
path_get(RARCH_PATH_CORE_OPTIONS));
path_clear_core_options();
path_clear(RARCH_PATH_CORE_OPTIONS);
}
else
core_option_manager_flush(runloop_core_options);

View File

@ -1008,7 +1008,7 @@ static bool command_event_cmd_exec(const char *data,
if (fullpath != (void*)data)
{
path_clear_content();
path_clear(RARCH_PATH_CONTENT);
if (!string_is_empty(data))
path_set(RARCH_PATH_CONTENT, data);
}
@ -1096,7 +1096,7 @@ bool task_push_content_load_default(
case CONTENT_MODE_LOAD_NOTHING_WITH_CURRENT_CORE_FROM_MENU:
case CONTENT_MODE_LOAD_NOTHING_WITH_VIDEO_PROCESSOR_CORE_FROM_MENU:
case CONTENT_MODE_LOAD_NOTHING_WITH_NET_RETROPAD_CORE_FROM_MENU:
path_clear_content();
path_clear(RARCH_PATH_CONTENT);
break;
default:
break;

View File

@ -329,7 +329,7 @@ static void open_core_handler(ui_browser_window_state_t *state, bool result)
&& settings->set_supports_no_game_enable)
{
content_ctx_info_t content_info = {0};
path_clear_content();
path_clear(RARCH_PATH_CONTENT);
task_push_content_load_default(
NULL, NULL,
&content_info,