From 9e9723e72170b87ba20e17883a221c2ec5b4481f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 7 Feb 2016 02:50:16 +0100 Subject: [PATCH] Create CORE_INFO_CTL_FIND --- core_info.c | 24 +++++++++++++++++------- core_info.h | 9 ++++++++- menu/cbs/menu_cbs_ok.c | 10 +++++----- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/core_info.c b/core_info.c index 7750c12abf..c7b1ca1113 100644 --- a/core_info.c +++ b/core_info.c @@ -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; diff --git a/core_info.h b/core_info.h index 77c1509ae4..13ba6ea95b 100644 --- a/core_info.h +++ b/core_info.h @@ -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); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 25c907ee40..ca0d060aa9 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -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,