Skip to content

Commit

Permalink
Simplify core_info_list_get_all_extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 14, 2015
1 parent ad1b433 commit c8b041e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
10 changes: 6 additions & 4 deletions core_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,13 @@ bool core_info_does_support_file(const core_info_t *core, const char *path)
core->supported_extensions_list, ".", path_get_extension(path));
}

const char *core_info_list_get_all_extensions(core_info_list_t *core_info_list)
const char *core_info_list_get_all_extensions(void)
{
if (!core_info_list)
return "";
return core_info_list->all_ext;
global_t *global = global_get_ptr();
core_info_list_t *list = (global->core_info.list) ? global->core_info.list : NULL;
if (!list)
return NULL;
return list->all_ext;
}

/* qsort_r() is not in standard C, sadly. */
Expand Down
2 changes: 1 addition & 1 deletion core_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void core_info_list_update_missing_firmware(core_info_list_t *list,
bool core_info_list_get_info(core_info_list_t *list,
core_info_t *info, const char *path);

const char *core_info_list_get_all_extensions(core_info_list_t *list);
const char *core_info_list_get_all_extensions(void);

bool core_info_list_get_display_name(core_info_list_t *list,
const char *path, char *buf, size_t size);
Expand Down
3 changes: 1 addition & 2 deletions dir_list_special.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ struct string_list *dir_list_new_special(const char *input_dir, enum dir_list_ty
const char *exts = NULL;
bool include_dirs = false;

global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();

(void)input_dir;
Expand All @@ -39,7 +38,7 @@ struct string_list *dir_list_new_special(const char *input_dir, enum dir_list_ty
break;
case DIR_LIST_CORE_INFO:
dir = input_dir;
exts = (global->core_info.list) ? core_info_list_get_all_extensions(global->core_info.list) : NULL;
exts = core_info_list_get_all_extensions();
break;
case DIR_LIST_SHADERS:
dir = settings->video.shader_dir;
Expand Down
14 changes: 7 additions & 7 deletions menu/cbs/menu_cbs_deferred_push.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned typ
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
rarch_system_info_t *system = rarch_system_info_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
const char *exts = core_info_list_get_all_extensions();

switch (id)
{
Expand All @@ -327,9 +328,9 @@ static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned typ
{
case PUSH_ARCHIVE_OPEN_DETECT_CORE:
info->setting = menu_setting_find(info->label);
if (global->core_info.list)
strlcpy(info->exts, core_info_list_get_all_extensions(
global->core_info.list), sizeof(info->exts));

if (exts)
strlcpy(info->exts, exts, sizeof(info->exts));
else if (global->menu.info.valid_extensions)
{
if (*global->menu.info.valid_extensions)
Expand Down Expand Up @@ -363,9 +364,8 @@ static int general_push(menu_displaylist_info_t *info, unsigned id, unsigned typ
strlcpy(info->exts, system->valid_extensions, sizeof(info->exts));
break;
case PUSH_DETECT_CORE_LIST:
if (global->core_info.list)
strlcpy(info->exts, core_info_list_get_all_extensions(
global->core_info.list), sizeof(info->exts));
if (exts)
strlcpy(info->exts, exts, sizeof(info->exts));
break;
}

Expand Down

0 comments on commit c8b041e

Please sign in to comment.