Refactor some code in task_push_decompress

This commit is contained in:
twinaphex 2016-06-20 15:21:42 +02:00
parent 7d93f63e6a
commit 7d3780e09f
2 changed files with 10 additions and 6 deletions

View File

@ -22,6 +22,7 @@
#include "configuration.h"
int menu_hash_get_help(uint32_t hash, char *s, size_t len)
{
int ret = -1;
@ -126,11 +127,18 @@ uint32_t msg_hash_calculate(const char *s)
return djb2_calculate(s);
}
#define FILE_HASH_ZIP 0x0b88c7d8U
#define FILE_HASH_ZIP_UPP 0x0b883b78U
#define FILE_HASH_APK 0x0b885e61U
enum menu_file_type menu_hash_to_file_type(uint32_t hash)
{
switch (hash)
{
case MENU_VALUE_COMP:
case FILE_HASH_ZIP:
case FILE_HASH_ZIP_UPP:
case FILE_HASH_APK:
return MENU_FILE_COMPRESSED;
case MENU_VALUE_MORE:
return MENU_FILE_MORE;

View File

@ -250,7 +250,6 @@ bool task_push_decompress(
char tmp[PATH_MAX_LENGTH] = {0};
decompress_state_t *s = NULL;
retro_task_t *t = NULL;
bool is_compressed = false;
if (string_is_empty(target_dir) || string_is_empty(source_file))
{
@ -260,11 +259,8 @@ bool task_push_decompress(
}
/* ZIP or APK only */
is_compressed = string_is_equal(path_get_extension(source_file), "zip");
is_compressed = is_compressed ||
string_is_equal(path_get_extension(source_file), "apk");
if (!path_file_exists(source_file) || !is_compressed)
if (!path_file_exists(source_file) ||
!menu_hash_to_file_type(msg_hash_calculate(path_get_extension(source_file))))
{
RARCH_WARN("[decompress] File '%s' does not exist or is not a compressed file.\n",
source_file);