diff --git a/Makefile.common b/Makefile.common
index 57c73704ff..b864e189b6 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -313,6 +313,7 @@ ifeq ($(HAVE_MENU_COMMON), 1)
menu/menu_common_list.o \
menu/menu_navigation.o \
menu/menu_action.o \
+ menu/menu_database.o \
menu/menu_shader.o \
menu/menu_entries.o \
menu/menu_entries_cbs.o \
diff --git a/menu/menu_database.c b/menu/menu_database.c
new file mode 100644
index 0000000000..aae0aa2a78
--- /dev/null
+++ b/menu/menu_database.c
@@ -0,0 +1,60 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2011-2015 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#include "menu.h"
+#include "menu_database.h"
+#include "menu_list.h"
+#include
+
+int menu_database_populate_list(file_list_t *list, const char *path)
+{
+#ifdef HAVE_LIBRETRODB
+ int rv = 1, i;
+ libretrodb_t db;
+ libretrodb_cursor_t cur;
+ struct rmsgpack_dom_value item;
+ const core_info_t *info = NULL;
+
+ if ((rv = libretrodb_open(path, &db)) != 0)
+ return -1;
+
+ if ((rv = libretrodb_cursor_open(&db, &cur, NULL)) != 0)
+ return -1;
+
+ 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 (!strcmp(key->string.buff, "description"))
+ {
+ menu_list_push(list, val->string.buff, "",
+ MENU_FILE_RDB_ENTRY, 0);
+ break;
+ }
+ }
+ }
+
+ libretrodb_cursor_close(&cur);
+ libretrodb_close(&db);
+#endif
+
+ return 0;
+}
diff --git a/menu/menu_database.h b/menu/menu_database.h
new file mode 100644
index 0000000000..8f3c6e25ff
--- /dev/null
+++ b/menu/menu_database.h
@@ -0,0 +1,36 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2011-2015 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#ifndef _MENU_DATABASE_H
+#define _MENU_DATABASE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include
+#include "../core_info.h"
+#include
+#ifdef HAVE_LIBRETRODB
+#include "../libretrodb/libretrodb.h"
+#endif
+
+int menu_database_populate_list(file_list_t *list, const char *path);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/menu/menu_entries_cbs.c b/menu/menu_entries_cbs.c
index 435319ad2c..c9ef6784e9 100644
--- a/menu/menu_entries_cbs.c
+++ b/menu/menu_entries_cbs.c
@@ -32,9 +32,7 @@
#include "../net_http.h"
#endif
-#ifdef HAVE_LIBRETRODB
-#include "../libretrodb/libretrodb.h"
-#endif
+#include "menu_database.h"
#include "../input/input_remapping.h"
@@ -1638,53 +1636,18 @@ static int deferred_push_database_manager_list_deferred(void *data, void *userda
const char *path, const char *label, unsigned type)
{
unsigned i;
-#ifdef HAVE_LIBRETRODB
- int rv = 1;
- libretrodb_t db;
- libretrodb_cursor_t cur;
- struct rmsgpack_dom_value item;
- const core_info_t *info = NULL;
-#endif
file_list_t *list = (file_list_t*)data;
file_list_t *menu_list = (file_list_t*)userdata;
if (!list || !menu_list)
return -1;
- (void)info;
- (void)rv;
-
menu_list_clear(list);
-#ifdef HAVE_LIBRETRODB
- if ((rv = libretrodb_open(path, &db)) != 0)
- return -1;
- if ((rv = libretrodb_cursor_open(&db, &cur, NULL)) != 0)
- return -1;
+ menu_database_populate_list(list, path);
- 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 (!strcmp(key->string.buff, "description"))
- {
- menu_list_push(list, val->string.buff, "",
- MENU_FILE_RDB_ENTRY, 0);
- break;
- }
- }
- }
-
- libretrodb_cursor_close(&cur);
- libretrodb_close(&db);
-#endif
menu_list_sort_on_alt(list);
+
driver.menu->scroll_indices_size = 0;
menu_entries_build_scroll_indices(list);
menu_entries_refresh(list);