mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Move menu_database_populate_query
This commit is contained in:
parent
ce1110eac6
commit
5cd5c043bc
@ -91,60 +91,6 @@ int menu_database_build_query(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBRETRODB
|
|
||||||
static int menu_database_push_query(libretrodb_t *db,
|
|
||||||
libretrodb_cursor_t *cur, file_list_t *list)
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
struct rmsgpack_dom_value item;
|
|
||||||
|
|
||||||
while (libretrodb_cursor_read_item(cur, &item) == 0)
|
|
||||||
{
|
|
||||||
if (item.type != RDT_MAP)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (i = 0; i < item.map.len; i++)
|
|
||||||
{
|
|
||||||
struct rmsgpack_dom_value *key = &item.map.items[i].key;
|
|
||||||
struct rmsgpack_dom_value *val = &item.map.items[i].value;
|
|
||||||
|
|
||||||
if (!key || !val)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!strcmp(key->string.buff, "name"))
|
|
||||||
{
|
|
||||||
menu_list_push(list, val->string.buff, db->path,
|
|
||||||
MENU_FILE_RDB_ENTRY, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int menu_database_populate_query(file_list_t *list, const char *path,
|
|
||||||
const char *query)
|
|
||||||
{
|
|
||||||
#ifdef HAVE_LIBRETRODB
|
|
||||||
libretrodb_t db;
|
|
||||||
libretrodb_cursor_t cur;
|
|
||||||
|
|
||||||
if ((libretrodb_open(path, &db)) != 0)
|
|
||||||
return -1;
|
|
||||||
if ((database_open_cursor(&db, &cur, query) != 0))
|
|
||||||
return -1;
|
|
||||||
if ((menu_database_push_query(&db, &cur, list)) != 0)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
libretrodb_cursor_close(&cur);
|
|
||||||
libretrodb_close(&db);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void menu_database_playlist_free(menu_handle_t *menu)
|
static void menu_database_playlist_free(menu_handle_t *menu)
|
||||||
{
|
{
|
||||||
if (menu->db_playlist)
|
if (menu->db_playlist)
|
||||||
|
@ -31,9 +31,6 @@ extern "C" {
|
|||||||
/* HACK */
|
/* HACK */
|
||||||
extern unsigned int rdb_entry_start_game_selection_ptr;
|
extern unsigned int rdb_entry_start_game_selection_ptr;
|
||||||
|
|
||||||
int menu_database_populate_query(file_list_t *list, const char *path,
|
|
||||||
const char *query);
|
|
||||||
|
|
||||||
int menu_database_build_query(
|
int menu_database_build_query(
|
||||||
char *query, size_t len, const char *label, const char *path);
|
char *query, size_t len, const char *label, const char *path);
|
||||||
|
|
||||||
|
@ -1771,6 +1771,60 @@ static int menu_displaylist_parse_database_entry(menu_displaylist_info_t *info)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBRETRODB
|
||||||
|
static int menu_database_push_query(libretrodb_t *db,
|
||||||
|
libretrodb_cursor_t *cur, file_list_t *list)
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
struct rmsgpack_dom_value item;
|
||||||
|
|
||||||
|
while (libretrodb_cursor_read_item(cur, &item) == 0)
|
||||||
|
{
|
||||||
|
if (item.type != RDT_MAP)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (i = 0; i < item.map.len; i++)
|
||||||
|
{
|
||||||
|
struct rmsgpack_dom_value *key = &item.map.items[i].key;
|
||||||
|
struct rmsgpack_dom_value *val = &item.map.items[i].value;
|
||||||
|
|
||||||
|
if (!key || !val)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!strcmp(key->string.buff, "name"))
|
||||||
|
{
|
||||||
|
menu_list_push(list, val->string.buff, db->path,
|
||||||
|
MENU_FILE_RDB_ENTRY, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int menu_database_populate_query(file_list_t *list, const char *path,
|
||||||
|
const char *query)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_LIBRETRODB
|
||||||
|
libretrodb_t db;
|
||||||
|
libretrodb_cursor_t cur;
|
||||||
|
|
||||||
|
if ((libretrodb_open(path, &db)) != 0)
|
||||||
|
return -1;
|
||||||
|
if ((database_open_cursor(&db, &cur, query) != 0))
|
||||||
|
return -1;
|
||||||
|
if ((menu_database_push_query(&db, &cur, list)) != 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
libretrodb_cursor_close(&cur);
|
||||||
|
libretrodb_close(&db);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type)
|
int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -1942,7 +1996,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type)
|
|||||||
break;
|
break;
|
||||||
case DISPLAYLIST_DATABASE_QUERY:
|
case DISPLAYLIST_DATABASE_QUERY:
|
||||||
menu_list_clear(info->list);
|
menu_list_clear(info->list);
|
||||||
menu_database_populate_query(info->list, info->path, (info->path_c[0] == '\0') ? NULL : info->path_c);
|
ret = menu_database_populate_query(info->list, info->path, (info->path_c[0] == '\0') ? NULL : info->path_c);
|
||||||
|
|
||||||
need_sort = true;
|
need_sort = true;
|
||||||
need_refresh = true;
|
need_refresh = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user