diff --git a/database_info.c b/database_info.c
index 7214ef7895..1238d6d27b 100644
--- a/database_info.c
+++ b/database_info.c
@@ -15,15 +15,16 @@
* If not, see .
*/
-#include "database_info.h"
-#include "hash.h"
-#include "file_ops.h"
-#include
-#include "general.h"
-#include "runloop.h"
#include
#include "file_ext.h"
#include
+#include
+
+#include "database_info.h"
+#include "hash.h"
+#include "file_ops.h"
+#include "general.h"
+#include "runloop.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -47,17 +48,6 @@ int database_open_cursor(libretrodb_t *db,
return 0;
}
-#ifdef HAVE_ZLIB
-static int zlib_compare_crc32(const char *name, const char *valid_exts,
- const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
- uint32_t crc32, void *userdata)
-{
- RARCH_LOG("CRC32: 0x%x\n", crc32);
-
- return 1;
-}
-#endif
-
database_info_handle_t *database_info_init(const char *dir, enum database_type type)
{
const char *exts = "";
@@ -96,91 +86,6 @@ void database_info_free(database_info_handle_t *db)
free(db);
}
-static int database_info_iterate_rdl_write(
- database_info_handle_t *db, const char *name)
-{
- char parent_dir[PATH_MAX_LENGTH];
- bool to_continue = (db->list_ptr < db->list->size);
-
- if (!to_continue)
- {
- rarch_main_msg_queue_push("Scanning of directory finished.\n", 1, 180, true);
- db->status = DATABASE_STATUS_FREE;
- return -1;
- }
-
- path_parent_dir(parent_dir);
-
- if (!strcmp(path_get_extension(name), "zip"))
- {
-#ifdef HAVE_ZLIB
- RARCH_LOG("[ZIP]: name: %s\n", name);
-
- if (!zlib_parse_file(name, NULL, zlib_compare_crc32,
- (void*)parent_dir))
- RARCH_LOG("Could not process ZIP file.\n");
-#endif
- }
- else
- {
- char msg[PATH_MAX_LENGTH];
- ssize_t ret;
- uint32_t crc, target_crc = 0;
- uint8_t *ret_buf = NULL;
- int read_from = read_file(name, (void**)&ret_buf, &ret);
-
- (void)target_crc;
-
- if (read_from != 1)
- return 0;
- if (ret <= 0)
- return 0;
-
- snprintf(msg, sizeof(msg), "%zu/%zu: Scanning %s...\n",
- db->list_ptr, db->list->size, name);
-
- rarch_main_msg_queue_push(msg, 1, 180, true);
-
-#ifdef HAVE_ZLIB
- crc = zlib_crc32_calculate(ret_buf, ret);
-
- RARCH_LOG("CRC32: 0x%x .\n", (unsigned)crc);
-#endif
-
- if (ret_buf)
- free(ret_buf);
- }
-
- db->list_ptr++;
-
- return 0;
-}
-
-int database_info_iterate(database_info_handle_t *db)
-{
- const char *name = NULL;
-
- if (!db || !db->list)
- return -1;
-
- name = db->list->elems[db->list_ptr].data;
-
- if (!name)
- return 0;
-
- switch (db->type)
- {
- case DATABASE_TYPE_NONE:
- break;
- case DATABASE_TYPE_RDL_WRITE:
- if (database_info_iterate_rdl_write(db, name) != 0)
- return -1;
- break;
- }
-
- return 0;
-}
-
static char *bin_to_hex_alloc(const uint8_t *data, size_t len)
{
size_t i;
diff --git a/database_info.h b/database_info.h
index 398ec4679e..d5f0ff14f8 100644
--- a/database_info.h
+++ b/database_info.h
@@ -96,8 +96,6 @@ database_info_handle_t *database_info_init(const char *dir,
void database_info_free(database_info_handle_t *dbl);
-int database_info_iterate(database_info_handle_t *dbl);
-
#ifdef __cplusplus
}
#endif
diff --git a/tasks/task_database.c b/tasks/task_database.c
index 494b04d8a6..33470052f5 100644
--- a/tasks/task_database.c
+++ b/tasks/task_database.c
@@ -12,14 +12,115 @@
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see .
*/
+#include
+#include "file_ext.h"
+#include
#include "../menu/menu_driver.h"
+#include "../general.h"
#include "../runloop_data.h"
#include "tasks.h"
+
#ifdef HAVE_LIBRETRODB
#ifdef HAVE_MENU
+
+#ifdef HAVE_ZLIB
+static int zlib_compare_crc32(const char *name, const char *valid_exts,
+ const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
+ uint32_t crc32, void *userdata)
+{
+ RARCH_LOG("CRC32: 0x%x\n", crc32);
+
+ return 1;
+}
+#endif
+static int database_info_iterate_rdl_write(
+ database_info_handle_t *db, const char *name)
+{
+ char parent_dir[PATH_MAX_LENGTH];
+ bool to_continue = (db->list_ptr < db->list->size);
+
+ if (!to_continue)
+ {
+ rarch_main_msg_queue_push("Scanning of directory finished.\n", 1, 180, true);
+ db->status = DATABASE_STATUS_FREE;
+ return -1;
+ }
+
+ path_parent_dir(parent_dir);
+
+ if (!strcmp(path_get_extension(name), "zip"))
+ {
+#ifdef HAVE_ZLIB
+ RARCH_LOG("[ZIP]: name: %s\n", name);
+
+ if (!zlib_parse_file(name, NULL, zlib_compare_crc32,
+ (void*)parent_dir))
+ RARCH_LOG("Could not process ZIP file.\n");
+#endif
+ }
+ else
+ {
+ char msg[PATH_MAX_LENGTH];
+ ssize_t ret;
+ uint32_t crc, target_crc = 0;
+ uint8_t *ret_buf = NULL;
+ int read_from = read_file(name, (void**)&ret_buf, &ret);
+
+ (void)target_crc;
+
+ if (read_from != 1)
+ return 0;
+ if (ret <= 0)
+ return 0;
+
+ snprintf(msg, sizeof(msg), "%zu/%zu: Scanning %s...\n",
+ db->list_ptr, db->list->size, name);
+
+ rarch_main_msg_queue_push(msg, 1, 180, true);
+
+#ifdef HAVE_ZLIB
+ crc = zlib_crc32_calculate(ret_buf, ret);
+
+ RARCH_LOG("CRC32: 0x%x .\n", (unsigned)crc);
+#endif
+
+ if (ret_buf)
+ free(ret_buf);
+ }
+
+ db->list_ptr++;
+
+ return 0;
+}
+
+static int database_info_iterate(database_info_handle_t *db)
+{
+ const char *name = NULL;
+
+ if (!db || !db->list)
+ return -1;
+
+ name = db->list->elems[db->list_ptr].data;
+
+ if (!name)
+ return 0;
+
+ switch (db->type)
+ {
+ case DATABASE_TYPE_NONE:
+ break;
+ case DATABASE_TYPE_RDL_WRITE:
+ if (database_info_iterate_rdl_write(db, name) != 0)
+ return -1;
+ break;
+ }
+
+ return 0;
+}
+
void rarch_main_data_db_iterate(bool is_thread, void *data)
{
data_runloop_t *runloop = (data_runloop_t*)data;