mirror of
https://github.com/libretro/RetroArch
synced 2025-03-30 07:20:36 +00:00
core_info_get_name and content_playlist_update
This commit is contained in:
parent
50700ed7d3
commit
18e68918f3
65
core_info.c
65
core_info.c
@ -100,6 +100,71 @@ static void core_info_list_resolve_all_firmware(
|
||||
}
|
||||
}
|
||||
|
||||
void core_info_get_name(const char *path, char *s, size_t len)
|
||||
{
|
||||
size_t i;
|
||||
core_info_t *core_info = NULL;
|
||||
core_info_list_t *core_info_list = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
struct string_list *contents = dir_list_new_special(NULL, DIR_LIST_CORES);
|
||||
|
||||
if (!contents)
|
||||
return NULL;
|
||||
|
||||
core_info_list = (core_info_list_t*)calloc(1, sizeof(*core_info_list));
|
||||
if (!core_info_list)
|
||||
goto error;
|
||||
|
||||
core_info = (core_info_t*)calloc(contents->size, sizeof(*core_info));
|
||||
if (!core_info)
|
||||
goto error;
|
||||
|
||||
core_info_list->list = core_info;
|
||||
core_info_list->count = contents->size;
|
||||
|
||||
for (i = 0; i < contents->size; i++)
|
||||
{
|
||||
char info_path_base[PATH_MAX_LENGTH], info_path[PATH_MAX_LENGTH];
|
||||
core_info[i].path = strdup(contents->elems[i].data);
|
||||
|
||||
if (!core_info[i].path)
|
||||
break;
|
||||
|
||||
if (strcmp(core_info[i].path, path) != 0)
|
||||
continue;
|
||||
|
||||
fill_pathname_base(info_path_base, contents->elems[i].data,
|
||||
sizeof(info_path_base));
|
||||
path_remove_extension(info_path_base);
|
||||
|
||||
#if defined(RARCH_MOBILE) || (defined(RARCH_CONSOLE) && !defined(PSP))
|
||||
char *substr = strrchr(info_path_base, '_');
|
||||
if (substr)
|
||||
*substr = '\0';
|
||||
#endif
|
||||
|
||||
strlcat(info_path_base, ".info", sizeof(info_path_base));
|
||||
|
||||
fill_pathname_join(info_path, (*settings->libretro_info_path) ?
|
||||
settings->libretro_info_path : settings->libretro_directory,
|
||||
info_path_base, sizeof(info_path));
|
||||
|
||||
core_info[i].data = config_file_new(info_path);
|
||||
|
||||
if (core_info[i].data)
|
||||
config_get_string(core_info[i].data, "corename",
|
||||
&core_info[i].core_name);
|
||||
|
||||
strlcpy(s, core_info[i].core_name, len);
|
||||
}
|
||||
|
||||
error:
|
||||
if (contents)
|
||||
dir_list_free(contents);
|
||||
contents = NULL;
|
||||
core_info_list_free(core_info_list);
|
||||
}
|
||||
|
||||
core_info_list_t *core_info_list_new(void)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -104,6 +104,8 @@ const char *core_info_list_get_all_extensions(core_info_list_t *list);
|
||||
bool core_info_list_get_display_name(core_info_list_t *list,
|
||||
const char *path, char *buf, size_t size);
|
||||
|
||||
void core_info_get_name(const char *path, char *s, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -505,7 +505,8 @@ void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
|
||||
cbs->action_deferred_push = deferred_push_category;
|
||||
else if (type == MENU_FILE_PLAYLIST_COLLECTION)
|
||||
cbs->action_deferred_push = deferred_push_rdb_collection;
|
||||
else if (!strcmp(label, "deferred_core_list"))
|
||||
else if (!strcmp(label, "deferred_core_list") ||
|
||||
!strcmp(label, "deferred_core_list_set"))
|
||||
cbs->action_deferred_push = deferred_push_core_list_deferred;
|
||||
else if (!strcmp(label, "deferred_video_filter"))
|
||||
cbs->action_deferred_push = deferred_push_video_filter;
|
||||
|
@ -73,7 +73,10 @@ static int action_ok_file_load_with_detect_core(const char *path,
|
||||
info.type = 0;
|
||||
info.directory_ptr = idx;
|
||||
strlcpy(info.path, settings->libretro_directory, sizeof(info.path));
|
||||
strlcpy(info.label, "deferred_core_list", sizeof(info.label));
|
||||
if (!strcmp(label, "collection"))
|
||||
strlcpy(info.label, "deferred_core_list_set", sizeof(info.label));
|
||||
else
|
||||
strlcpy(info.label, "deferred_core_list", sizeof(info.label));
|
||||
|
||||
ret = menu_displaylist_push_list(&info, DISPLAYLIST_GENERIC);
|
||||
}
|
||||
@ -785,6 +788,31 @@ static int action_ok_path_use_directory(const char *path,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int action_ok_core_deferred_set(const char *path,
|
||||
const char *label, unsigned type, size_t idx)
|
||||
{
|
||||
char core_display_name[PATH_MAX_LENGTH];
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
content_playlist_t *playlist = menu ? menu->playlist : NULL;
|
||||
if (!menu)
|
||||
return -1;
|
||||
|
||||
core_info_get_name(path, core_display_name, sizeof(core_display_name));
|
||||
|
||||
content_playlist_update(playlist, idx,
|
||||
NULL, NULL,
|
||||
path , core_display_name,
|
||||
NULL);
|
||||
|
||||
content_playlist_write_file(playlist);
|
||||
content_playlist_free(playlist);
|
||||
menu->playlist = NULL;
|
||||
|
||||
menu_list_flush_stack(menu->menu_list, NULL, MENU_SETTINGS);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int action_ok_core_load_deferred(const char *path,
|
||||
const char *label, unsigned type, size_t idx)
|
||||
{
|
||||
@ -1560,6 +1588,8 @@ void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
|
||||
case MENU_FILE_CORE:
|
||||
if (!strcmp(menu_label, "deferred_core_list"))
|
||||
cbs->action_ok = action_ok_core_load_deferred;
|
||||
else if (!strcmp(menu_label, "deferred_core_list_set"))
|
||||
cbs->action_ok = action_ok_core_deferred_set;
|
||||
else if (!strcmp(menu_label, "core_list"))
|
||||
cbs->action_ok = action_ok_core_load;
|
||||
else if (!strcmp(menu_label, "core_updater_list"))
|
||||
|
27
playlist.c
27
playlist.c
@ -119,6 +119,33 @@ static void content_playlist_free_entry(content_playlist_entry_t *entry)
|
||||
memset(entry, 0, sizeof(*entry));
|
||||
}
|
||||
|
||||
void content_playlist_update(content_playlist_t *playlist, size_t idx,
|
||||
const char *path, const char *label,
|
||||
const char *core_path, const char *core_name,
|
||||
const char *crc32)
|
||||
{
|
||||
if (!playlist)
|
||||
return;
|
||||
idx = idx - 1;
|
||||
if (idx > playlist->size)
|
||||
return;
|
||||
|
||||
if (path != NULL)
|
||||
playlist->entries[idx].path = strdup(path);
|
||||
if (label != NULL)
|
||||
playlist->entries[idx].label = strdup(label);
|
||||
if (core_path != NULL)
|
||||
{
|
||||
playlist->entries[idx].core_path = strdup(core_path);
|
||||
}
|
||||
if (core_name != NULL)
|
||||
{
|
||||
playlist->entries[idx].core_name = strdup(core_name);
|
||||
}
|
||||
if (crc32 != NULL)
|
||||
playlist->entries[idx].crc32 = strdup(crc32);
|
||||
}
|
||||
|
||||
/**
|
||||
* content_playlist_push:
|
||||
* @playlist : Playlist handle.
|
||||
|
@ -108,6 +108,11 @@ void content_playlist_push(content_playlist_t *playlist,
|
||||
const char *core_path, const char *core_name,
|
||||
const char *crc32);
|
||||
|
||||
void content_playlist_update(content_playlist_t *playlist, size_t idx,
|
||||
const char *path, const char *label,
|
||||
const char *core_path, const char *core_name,
|
||||
const char *crc32);
|
||||
|
||||
void content_playlist_get_index_by_path(content_playlist_t *playlist,
|
||||
const char *search_path,
|
||||
char **path, char **label,
|
||||
|
Loading…
x
Reference in New Issue
Block a user