mirror of
https://github.com/libretro/RetroArch
synced 2025-02-22 03:40:43 +00:00
Very primitive directory scanning of CRCs - prototype
This commit is contained in:
parent
73aa0ff177
commit
a55e48e88c
@ -16,6 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "database_info.h"
|
#include "database_info.h"
|
||||||
|
#include "hash.h"
|
||||||
|
#include "file_ops.h"
|
||||||
|
#include "file_extract.h"
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include <file/file_path.h>
|
#include <file/file_path.h>
|
||||||
#include "file_ext.h"
|
#include "file_ext.h"
|
||||||
@ -43,6 +46,76 @@ int database_open_cursor(libretrodb_t *db,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
static bool 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 true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int database_info_write_rdl(const char *dir)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
const char *exts = "";
|
||||||
|
struct string_list *str_list = NULL;
|
||||||
|
|
||||||
|
if (g_extern.core_info)
|
||||||
|
exts = core_info_list_get_all_extensions(g_extern.core_info);
|
||||||
|
|
||||||
|
str_list = (struct string_list*)dir_list_new(dir, exts, false);
|
||||||
|
|
||||||
|
if (!str_list)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; i < str_list->size; i++)
|
||||||
|
{
|
||||||
|
char parent_dir[PATH_MAX_LENGTH];
|
||||||
|
const char *name = str_list->elems[i].data;
|
||||||
|
if (!name)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
path_parent_dir(parent_dir);
|
||||||
|
|
||||||
|
#ifdef HAVE_ZLIB
|
||||||
|
if (!strcmp(path_get_extension(name), "zip"))
|
||||||
|
{
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
ssize_t ret;
|
||||||
|
uint32_t crc, target_crc;
|
||||||
|
uint8_t *ret_buf = NULL;
|
||||||
|
|
||||||
|
RARCH_LOG("name: %s\n", name);
|
||||||
|
ret = read_file(name, (void**)&ret_buf);
|
||||||
|
|
||||||
|
if (ret <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
crc = crc32_calculate(ret_buf, ret);
|
||||||
|
|
||||||
|
RARCH_LOG("CRC32: 0x%x .\n", (unsigned)crc);
|
||||||
|
|
||||||
|
if (ret_buf)
|
||||||
|
free(ret_buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string_list_free(str_list);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
database_info_list_t *database_info_list_new(const char *rdb_path, const char *query)
|
database_info_list_t *database_info_list_new(const char *rdb_path, const char *query)
|
||||||
{
|
{
|
||||||
libretrodb_t db;
|
libretrodb_t db;
|
||||||
|
@ -67,6 +67,8 @@ void database_info_list_free(database_info_list_t *list);
|
|||||||
int database_open_cursor(libretrodb_t *db,
|
int database_open_cursor(libretrodb_t *db,
|
||||||
libretrodb_cursor_t *cur, const char *query);
|
libretrodb_cursor_t *cur, const char *query);
|
||||||
|
|
||||||
|
int database_info_write_rdl(const char *dir);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user