Skip to content

Commit

Permalink
Create path_is_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 30, 2016
1 parent 2288860 commit 1266c06
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 62 deletions.
6 changes: 3 additions & 3 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
8 changes: 4 additions & 4 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion file_path_special.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion menu/cbs/menu_cbs_get_value.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion menu/menu_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
65 changes: 29 additions & 36 deletions paths.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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++)
Expand Down Expand Up @@ -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:
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)
{
if (string_is_empty(subsystem_path))
return true;

return false;
}

bool path_is_config_empty(void)
bool path_is_empty(enum rarch_path_type type)
{
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;
}
Expand Down Expand Up @@ -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)
{
Expand Down
10 changes: 1 addition & 9 deletions paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down
6 changes: 3 additions & 3 deletions tasks/task_content.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 1266c06

Please sign in to comment.