mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +00:00
Start adding Database Manager (stub for now). Also add some more
libretrodb documentation
This commit is contained in:
parent
1db3789090
commit
dfd8d55f7a
@ -297,7 +297,16 @@ int rarchdb_find_entry(
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int rarchdb_cursor_reset(struct rarchdb_cursor * cursor) {
|
/**
|
||||||
|
* rarchdb_cursor_reset:
|
||||||
|
* @cursor : Handle to database cursor.
|
||||||
|
*
|
||||||
|
* Resets cursor.
|
||||||
|
*
|
||||||
|
* Returns: ???.
|
||||||
|
**/
|
||||||
|
int rarchdb_cursor_reset(struct rarchdb_cursor * cursor)
|
||||||
|
{
|
||||||
cursor->eof = 0;
|
cursor->eof = 0;
|
||||||
return lseek(
|
return lseek(
|
||||||
cursor->fd,
|
cursor->fd,
|
||||||
@ -333,41 +342,58 @@ retry:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rarchdb_cursor_close(struct rarchdb_cursor * cursor) {
|
/**
|
||||||
|
* rarchdb_cursor_close:
|
||||||
|
* @cursor : Handle to database cursor.
|
||||||
|
*
|
||||||
|
* Closes cursor and frees up allocated memory.
|
||||||
|
**/
|
||||||
|
void rarchdb_cursor_close(struct rarchdb_cursor * cursor)
|
||||||
|
{
|
||||||
close(cursor->fd);
|
close(cursor->fd);
|
||||||
cursor->is_valid = 0;
|
cursor->is_valid = 0;
|
||||||
cursor->fd = -1;
|
cursor->fd = -1;
|
||||||
cursor->eof = 1;
|
cursor->eof = 1;
|
||||||
cursor->db = NULL;
|
cursor->db = NULL;
|
||||||
if (cursor->query) {
|
if (cursor->query)
|
||||||
rarchdb_query_free(cursor->query);
|
rarchdb_query_free(cursor->query);
|
||||||
}
|
|
||||||
cursor->query = NULL;
|
cursor->query = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rarchdb_cursor_open:
|
||||||
|
* @db : Handle to database.
|
||||||
|
* @cursor : Handle to database cursor.
|
||||||
|
* @q : Query to execute.
|
||||||
|
*
|
||||||
|
* Opens cursor to database based on query @q.
|
||||||
|
*
|
||||||
|
* Returns: 0 if successful, otherwise negative.
|
||||||
|
**/
|
||||||
int rarchdb_cursor_open(
|
int rarchdb_cursor_open(
|
||||||
struct rarchdb * db,
|
struct rarchdb * db,
|
||||||
struct rarchdb_cursor * cursor,
|
struct rarchdb_cursor * cursor,
|
||||||
rarchdb_query * q
|
rarchdb_query * q
|
||||||
) {
|
)
|
||||||
|
{
|
||||||
cursor->fd = dup(db->fd);
|
cursor->fd = dup(db->fd);
|
||||||
if (cursor->fd == -1) {
|
|
||||||
|
if (cursor->fd == -1)
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
|
||||||
cursor->db = db;
|
cursor->db = db;
|
||||||
cursor->is_valid = 1;
|
cursor->is_valid = 1;
|
||||||
rarchdb_cursor_reset(cursor);
|
rarchdb_cursor_reset(cursor);
|
||||||
cursor->query = q;
|
cursor->query = q;
|
||||||
if (q) {
|
|
||||||
|
if (q)
|
||||||
rarchdb_query_inc_ref(q);
|
rarchdb_query_inc_ref(q);
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int node_iter(
|
static int node_iter(void * value, void * ctx)
|
||||||
void * value,
|
{
|
||||||
void * ctx
|
|
||||||
){
|
|
||||||
struct node_iter_ctx * nictx = (struct node_iter_ctx *)ctx;
|
struct node_iter_ctx * nictx = (struct node_iter_ctx *)ctx;
|
||||||
|
|
||||||
if (write(nictx->db->fd, value, nictx->idx->key_size + sizeof(uint64_t)) > 0)
|
if (write(nictx->db->fd, value, nictx->idx->key_size + sizeof(uint64_t)) > 0)
|
||||||
@ -376,7 +402,8 @@ static int node_iter(
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t rarchdb_tell(struct rarchdb * db) {
|
static uint64_t rarchdb_tell(struct rarchdb * db)
|
||||||
|
{
|
||||||
return lseek(db->fd, 0, SEEK_CUR);
|
return lseek(db->fd, 0, SEEK_CUR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,14 +11,16 @@
|
|||||||
|
|
||||||
typedef void rarchdb_query;
|
typedef void rarchdb_query;
|
||||||
|
|
||||||
struct rarchdb {
|
struct rarchdb
|
||||||
|
{
|
||||||
int fd;
|
int fd;
|
||||||
uint64_t root;
|
uint64_t root;
|
||||||
uint64_t count;
|
uint64_t count;
|
||||||
uint64_t first_index_offset;
|
uint64_t first_index_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct rarchdb_cursor {
|
struct rarchdb_cursor
|
||||||
|
{
|
||||||
int is_valid;
|
int is_valid;
|
||||||
int fd;
|
int fd;
|
||||||
int eof;
|
int eof;
|
||||||
@ -38,6 +40,7 @@ int rarchdb_create(
|
|||||||
);
|
);
|
||||||
|
|
||||||
void rarchdb_close(struct rarchdb * db);
|
void rarchdb_close(struct rarchdb * db);
|
||||||
|
|
||||||
int rarchdb_open(
|
int rarchdb_open(
|
||||||
const char * path,
|
const char * path,
|
||||||
struct rarchdb * db
|
struct rarchdb * db
|
||||||
@ -55,14 +58,38 @@ int rarchdb_find_entry(
|
|||||||
struct rmsgpack_dom_value * out
|
struct rmsgpack_dom_value * out
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rarchdb_cursor_open:
|
||||||
|
* @db : Handle to database.
|
||||||
|
* @cursor : Handle to database cursor.
|
||||||
|
* @q : Query to execute.
|
||||||
|
*
|
||||||
|
* Opens cursor to database based on query @q.
|
||||||
|
*
|
||||||
|
* Returns: 0 if successful, otherwise negative.
|
||||||
|
**/
|
||||||
int rarchdb_cursor_open(
|
int rarchdb_cursor_open(
|
||||||
struct rarchdb * db,
|
struct rarchdb * db,
|
||||||
struct rarchdb_cursor * cursor,
|
struct rarchdb_cursor * cursor,
|
||||||
rarchdb_query * query
|
rarchdb_query * query
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rarchdb_cursor_reset:
|
||||||
|
* @cursor : Handle to database cursor.
|
||||||
|
*
|
||||||
|
* Resets cursor.
|
||||||
|
*
|
||||||
|
* Returns: ???.
|
||||||
|
**/
|
||||||
int rarchdb_cursor_reset(struct rarchdb_cursor * cursor);
|
int rarchdb_cursor_reset(struct rarchdb_cursor * cursor);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* rarchdb_cursor_close:
|
||||||
|
* @cursor : Handle to database cursor.
|
||||||
|
*
|
||||||
|
* Closes cursor and frees up allocated memory.
|
||||||
|
**/
|
||||||
void rarchdb_cursor_close(struct rarchdb_cursor * cursor);
|
void rarchdb_cursor_close(struct rarchdb_cursor * cursor);
|
||||||
|
|
||||||
rarchdb_query * rarchdb_query_compile(
|
rarchdb_query * rarchdb_query_compile(
|
||||||
|
@ -26,6 +26,8 @@ static void get_title(const char *label, const char *dir,
|
|||||||
snprintf(title, sizeof_title, "CORE SELECTION %s", dir);
|
snprintf(title, sizeof_title, "CORE SELECTION %s", dir);
|
||||||
if (!strcmp(label, "core_manager_list"))
|
if (!strcmp(label, "core_manager_list"))
|
||||||
snprintf(title, sizeof_title, "CORE MANAGER %s", dir);
|
snprintf(title, sizeof_title, "CORE MANAGER %s", dir);
|
||||||
|
if (!strcmp(label, "database_manager_list"))
|
||||||
|
snprintf(title, sizeof_title, "DATABASE SELECTION %s", dir);
|
||||||
else if (!strcmp(label, "deferred_core_list"))
|
else if (!strcmp(label, "deferred_core_list"))
|
||||||
snprintf(title, sizeof_title, "DETECTED CORES %s", dir);
|
snprintf(title, sizeof_title, "DETECTED CORES %s", dir);
|
||||||
else if (!strcmp(label, "configurations"))
|
else if (!strcmp(label, "configurations"))
|
||||||
|
@ -78,6 +78,7 @@ typedef enum
|
|||||||
MENU_FILE_REMAP,
|
MENU_FILE_REMAP,
|
||||||
MENU_FILE_DOWNLOAD_CORE,
|
MENU_FILE_DOWNLOAD_CORE,
|
||||||
MENU_FILE_DOWNLOAD_CORE_INFO,
|
MENU_FILE_DOWNLOAD_CORE_INFO,
|
||||||
|
MENU_FILE_RDB,
|
||||||
MENU_SETTINGS,
|
MENU_SETTINGS,
|
||||||
MENU_SETTING_DRIVER,
|
MENU_SETTING_DRIVER,
|
||||||
MENU_SETTING_ACTION,
|
MENU_SETTING_ACTION,
|
||||||
|
@ -2346,6 +2346,13 @@ static int generic_deferred_push(void *data, void *userdata,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int deferred_push_database_manager_list(void *data, void *userdata,
|
||||||
|
const char *path, const char *label, unsigned type)
|
||||||
|
{
|
||||||
|
return generic_deferred_push(data, userdata, g_settings.content_database, label, type,
|
||||||
|
MENU_FILE_RDB, "rdb");
|
||||||
|
}
|
||||||
|
|
||||||
static int deferred_push_core_list(void *data, void *userdata,
|
static int deferred_push_core_list(void *data, void *userdata,
|
||||||
const char *path, const char *label, unsigned type)
|
const char *path, const char *label, unsigned type)
|
||||||
{
|
{
|
||||||
@ -2558,6 +2565,8 @@ static int menu_entries_cbs_init_bind_ok_first(menu_file_list_cbs_t *cbs,
|
|||||||
break;
|
break;
|
||||||
case MENU_FILE_DOWNLOAD_CORE_INFO:
|
case MENU_FILE_DOWNLOAD_CORE_INFO:
|
||||||
break;
|
break;
|
||||||
|
case MENU_FILE_RDB:
|
||||||
|
break;
|
||||||
case MENU_FILE_FONT:
|
case MENU_FILE_FONT:
|
||||||
case MENU_FILE_OVERLAY:
|
case MENU_FILE_OVERLAY:
|
||||||
case MENU_FILE_AUDIOFILTER:
|
case MENU_FILE_AUDIOFILTER:
|
||||||
@ -2708,6 +2717,7 @@ static void menu_entries_cbs_init_bind_ok(menu_file_list_cbs_t *cbs,
|
|||||||
cbs->action_ok = action_ok_push_content_list;
|
cbs->action_ok = action_ok_push_content_list;
|
||||||
else if (!strcmp(label, "history_list") ||
|
else if (!strcmp(label, "history_list") ||
|
||||||
!strcmp(label, "core_manager_list") ||
|
!strcmp(label, "core_manager_list") ||
|
||||||
|
!strcmp(label, "database_manager_list") ||
|
||||||
(setting && setting->browser_selection_type == ST_DIR)
|
(setting && setting->browser_selection_type == ST_DIR)
|
||||||
)
|
)
|
||||||
cbs->action_ok = action_ok_push_generic_list;
|
cbs->action_ok = action_ok_push_generic_list;
|
||||||
@ -2809,6 +2819,8 @@ static void menu_entries_cbs_init_bind_deferred_push(menu_file_list_cbs_t *cbs,
|
|||||||
cbs->action_deferred_push = deferred_push_core_manager_list;
|
cbs->action_deferred_push = deferred_push_core_manager_list;
|
||||||
else if (!strcmp(label, "history_list"))
|
else if (!strcmp(label, "history_list"))
|
||||||
cbs->action_deferred_push = deferred_push_history_list;
|
cbs->action_deferred_push = deferred_push_history_list;
|
||||||
|
else if (!strcmp(label, "database_manager_list"))
|
||||||
|
cbs->action_deferred_push = deferred_push_database_manager_list;
|
||||||
else if (!strcmp(label, "cheat_file_load"))
|
else if (!strcmp(label, "cheat_file_load"))
|
||||||
cbs->action_deferred_push = deferred_push_cheat_file_load;
|
cbs->action_deferred_push = deferred_push_cheat_file_load;
|
||||||
else if (!strcmp(label, "remap_file_load"))
|
else if (!strcmp(label, "remap_file_load"))
|
||||||
|
@ -3330,7 +3330,7 @@ static bool setting_data_append_list_main_menu_options(
|
|||||||
#if defined(HAVE_DYNAMIC) || defined(HAVE_LIBRETRO_MANAGEMENT)
|
#if defined(HAVE_DYNAMIC) || defined(HAVE_LIBRETRO_MANAGEMENT)
|
||||||
CONFIG_ACTION(
|
CONFIG_ACTION(
|
||||||
"core_list",
|
"core_list",
|
||||||
"Core",
|
"Core Selection",
|
||||||
group_info.name,
|
group_info.name,
|
||||||
subgroup_info.name);
|
subgroup_info.name);
|
||||||
(*list)[list_info->index - 1].size = sizeof(g_settings.libretro);
|
(*list)[list_info->index - 1].size = sizeof(g_settings.libretro);
|
||||||
@ -3353,6 +3353,12 @@ static bool setting_data_append_list_main_menu_options(
|
|||||||
subgroup_info.name);
|
subgroup_info.name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CONFIG_ACTION(
|
||||||
|
"database_manager_list",
|
||||||
|
"Database Manager",
|
||||||
|
group_info.name,
|
||||||
|
subgroup_info.name);
|
||||||
|
|
||||||
if (g_settings.history_list_enable)
|
if (g_settings.history_list_enable)
|
||||||
{
|
{
|
||||||
CONFIG_ACTION(
|
CONFIG_ACTION(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user