Move hashes over to msg_hash.c

This commit is contained in:
twinaphex 2016-06-20 17:55:34 +02:00
parent 003f1ba913
commit c3eda56561
3 changed files with 25 additions and 22 deletions

View File

@ -181,6 +181,12 @@ uint32_t msg_hash_calculate(const char *s)
#define MENU_VALUE_SLANG 0x105ce63aU #define MENU_VALUE_SLANG 0x105ce63aU
#define MENU_VALUE_SLANGP 0x1bf9adeaU #define MENU_VALUE_SLANGP 0x1bf9adeaU
#define HASH_EXTENSION_ZIP 0x0b88c7d8U
#define HASH_EXTENSION_CUE 0x0b886782U
#define HASH_EXTENSION_CUE_UPPERCASE 0x0b87db22U
#define HASH_EXTENSION_ISO 0x0b8880d0U
#define HASH_EXTENSION_ISO_UPPERCASE 0x0b87f470U
enum menu_file_type msg_hash_to_file_type(uint32_t hash) enum menu_file_type msg_hash_to_file_type(uint32_t hash)
{ {
switch (hash) switch (hash)
@ -282,6 +288,12 @@ enum menu_file_type msg_hash_to_file_type(uint32_t hash)
case MENU_VALUE_FILE_BMP: case MENU_VALUE_FILE_BMP:
return FILE_TYPE_BMP; return FILE_TYPE_BMP;
#endif #endif
case HASH_EXTENSION_CUE:
case HASH_EXTENSION_CUE_UPPERCASE:
return FILE_TYPE_CUE;
case HASH_EXTENSION_ISO:
case HASH_EXTENSION_ISO_UPPERCASE:
return FILE_TYPE_ISO;
default: default:
break; break;
} }

View File

@ -103,6 +103,9 @@ enum menu_file_type
FILE_TYPE_TGA, FILE_TYPE_TGA,
FILE_TYPE_BMP, FILE_TYPE_BMP,
FILE_TYPE_CUE,
FILE_TYPE_ISO,
FILE_TYPE_LAST FILE_TYPE_LAST
}; };

View File

@ -34,12 +34,6 @@
#include "../runloop.h" #include "../runloop.h"
#include "../verbosity.h" #include "../verbosity.h"
#define HASH_EXTENSION_ZIP 0x0b88c7d8U
#define HASH_EXTENSION_CUE 0x0b886782U
#define HASH_EXTENSION_CUE_UPPERCASE 0x0b87db22U
#define HASH_EXTENSION_ISO 0x0b8880d0U
#define HASH_EXTENSION_ISO_UPPERCASE 0x0b87f470U
#ifndef COLLECTION_SIZE #ifndef COLLECTION_SIZE
#define COLLECTION_SIZE 99999 #define COLLECTION_SIZE 99999
#endif #endif
@ -198,41 +192,35 @@ static int task_database_iterate_playlist(
database_state_handle_t *db_state, database_state_handle_t *db_state,
database_info_handle_t *db, const char *name) database_info_handle_t *db, const char *name)
{ {
uint32_t extension_hash = 0;
char parent_dir[PATH_MAX_LENGTH] = {0}; char parent_dir[PATH_MAX_LENGTH] = {0};
path_parent_dir(parent_dir); path_parent_dir(parent_dir);
extension_hash = msg_hash_calculate(path_get_extension(name)); switch (msg_hash_to_file_type(msg_hash_calculate(path_get_extension(name))))
switch (extension_hash)
{ {
case HASH_EXTENSION_ZIP: case FILE_TYPE_COMPRESSED:
#ifdef HAVE_ZLIB #ifdef HAVE_ZLIB
db->type = DATABASE_TYPE_ITERATE_ZIP; db->type = DATABASE_TYPE_ITERATE_ZIP;
memset(&db->state, 0, sizeof(file_archive_transfer_t)); memset(&db->state, 0, sizeof(file_archive_transfer_t));
db_state->zip_name[0] = '\0'; db_state->zip_name[0] = '\0';
db->state.type = ZLIB_TRANSFER_INIT; db->state.type = ZLIB_TRANSFER_INIT;
return file_get_crc(db_state, name, &db_state->zip_crc); return file_get_crc(db_state, name, &db_state->zip_crc);
#else
break;
#endif #endif
case HASH_EXTENSION_CUE: case FILE_TYPE_CUE:
case HASH_EXTENSION_CUE_UPPERCASE:
db_state->serial[0] = '\0'; db_state->serial[0] = '\0';
cue_get_serial(db_state, db, name, db_state->serial); cue_get_serial(db_state, db, name, db_state->serial);
db->type = DATABASE_TYPE_SERIAL_LOOKUP; db->type = DATABASE_TYPE_SERIAL_LOOKUP;
return 1; break;
case HASH_EXTENSION_ISO: case FILE_TYPE_ISO:
case HASH_EXTENSION_ISO_UPPERCASE:
db_state->serial[0] = '\0'; db_state->serial[0] = '\0';
iso_get_serial(db_state, db, name, db_state->serial); iso_get_serial(db_state, db, name, db_state->serial);
db->type = DATABASE_TYPE_SERIAL_LOOKUP; db->type = DATABASE_TYPE_SERIAL_LOOKUP;
return 1;
default:
{
db->type = DATABASE_TYPE_CRC_LOOKUP;
return file_get_crc(db_state, name, &db_state->crc);
}
break; break;
default:
db->type = DATABASE_TYPE_CRC_LOOKUP;
return file_get_crc(db_state, name, &db_state->crc);
} }
return 1; return 1;