diff --git a/file_extract.c b/file_extract.c index 1bd01492a0..a24733d0cd 100644 --- a/file_extract.c +++ b/file_extract.c @@ -19,8 +19,6 @@ #include #include #include -#include "general.h" -#include "retroarch_logger.h" #include #include #include @@ -42,6 +40,10 @@ struct zlib_file_backend void (*free)(void *handle); /* Closes, unmaps and frees. */ }; +#ifndef END_OF_CENTRAL_DIR_SIGNATURE +#define END_OF_CENTRAL_DIR_SIGNATURE 0x06054b50 +#endif + #ifdef HAVE_MMAP #include #include @@ -314,7 +316,7 @@ bool zlib_parse_file(const char *file, const char *valid_exts, { if (footer <= data + 22) GOTO_END_ERROR(); - if (read_le(footer, 4) == 0x06054b50) + if (read_le(footer, 4) == END_OF_CENTRAL_DIR_SIGNATURE) { unsigned comment_len = read_le(footer + 20, 2); if (footer + 22 + comment_len == data + zip_size) @@ -383,6 +385,12 @@ struct zip_extract_userdata bool found_content; }; +enum +{ + ZLIB_MODE_UNCOMPRESSED = 0, + ZLIB_MODE_DEFLATE = 8, +} zlib_compression_mode; + static int zip_extract_cb(const char *name, const char *valid_exts, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size, @@ -406,12 +414,10 @@ static int zip_extract_cb(const char *name, const char *valid_exts, switch (cmode) { - /* Uncompressed. */ - case 0: + case ZLIB_MODE_UNCOMPRESSED: data->found_content = write_file(new_path, cdata, size); return false; - /* Deflate. */ - case 8: + case ZLIB_MODE_DEFLATE: if (zlib_inflate_data_to_file(new_path, valid_exts, cdata, csize, size, checksum)) {