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_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)
{
switch (hash)
@ -282,6 +288,12 @@ enum menu_file_type msg_hash_to_file_type(uint32_t hash)
case MENU_VALUE_FILE_BMP:
return FILE_TYPE_BMP;
#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:
break;
}

View File

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

View File

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