Create CORE_INFO_CTL_FIND

This commit is contained in:
twinaphex 2016-02-07 02:50:16 +01:00
parent 490c023fe3
commit 9e9723e721
3 changed files with 30 additions and 13 deletions

View File

@ -671,12 +671,12 @@ bool core_info_ctl(enum core_info_state state, void *data)
if (core_info_current)
free(core_info_current);
core_info_current = NULL;
return true;
break;
case CORE_INFO_CTL_CURRENT_CORE_INIT:
core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t));
if (!core_info_current)
return false;
return true;
break;
case CORE_INFO_CTL_CURRENT_CORE_GET:
{
core_info_t **core = (core_info_t**)data;
@ -684,15 +684,15 @@ bool core_info_ctl(enum core_info_state state, void *data)
return false;
*core = core_info_current;
}
return true;
break;
case CORE_INFO_CTL_LIST_DEINIT:
if (core_info_curr_list)
core_info_list_free(core_info_curr_list);
core_info_curr_list = NULL;
return true;
break;
case CORE_INFO_CTL_LIST_INIT:
core_info_curr_list = core_info_list_new();
return true;
break;
case CORE_INFO_CTL_LIST_GET:
{
core_info_list_t **core = (core_info_list_t**)data;
@ -700,8 +700,18 @@ bool core_info_ctl(enum core_info_state state, void *data)
return false;
*core = core_info_curr_list;
}
return true;
break;
case CORE_INFO_CTL_FIND:
{
core_info_ctx_find_t *info = (core_info_ctx_find_t*)data;
if (!info)
return false;
if (!core_info_curr_list)
return false;
if (!(info->inf = core_info_find(core_info_curr_list, info->path)))
return false;
}
break;
case CORE_INFO_CTL_NONE:
default:
break;

View File

@ -32,7 +32,8 @@ enum core_info_state
CORE_INFO_CTL_LIST_GET,
CORE_INFO_CTL_CURRENT_CORE_FREE,
CORE_INFO_CTL_CURRENT_CORE_INIT,
CORE_INFO_CTL_CURRENT_CORE_GET
CORE_INFO_CTL_CURRENT_CORE_GET,
CORE_INFO_CTL_FIND
};
typedef struct
@ -81,6 +82,12 @@ typedef struct
char *all_ext;
} core_info_list_t;
typedef struct core_info_ctx_find
{
core_info_t *inf;
const char *path;
} core_info_ctx_find_t;
core_info_list_t *core_info_list_new(void);
void core_info_list_free(core_info_list_t *list);

View File

@ -631,8 +631,7 @@ static int action_ok_playlist_entry(const char *path,
{
char new_core_path[PATH_MAX_LENGTH];
char new_display_name[PATH_MAX_LENGTH];
core_info_t *core_info = NULL;
core_info_list_t *list = NULL;
core_info_ctx_find_t core_info;
const char *entry_path = NULL;
const char *entry_crc32 = NULL;
const char *db_name = NULL;
@ -640,9 +639,10 @@ static int action_ok_playlist_entry(const char *path,
bool found_associated_core = menu_playlist_find_associated_core(
path_base, new_core_path, sizeof(new_core_path));
core_info_ctl(CORE_INFO_CTL_LIST_GET, &list);
core_info.inf = NULL;
core_info.path = new_core_path;
if (!(core_info = core_info_find(list, new_core_path)))
if (!core_info_ctl(CORE_INFO_CTL_FIND, &core_info))
found_associated_core = false;
if (!found_associated_core)
@ -654,7 +654,7 @@ static int action_ok_playlist_entry(const char *path,
content_playlist_get_index(tmp_playlist, selection_ptr,
&entry_path, &entry_label, NULL, NULL, &entry_crc32, &db_name);
strlcpy(new_display_name, core_info->display_name, sizeof(new_display_name));
strlcpy(new_display_name, core_info.inf->display_name, sizeof(new_display_name));
content_playlist_update(tmp_playlist,
selection_ptr,
entry_path,