From b73832ce2e6412ea220c4c767fd1257f67a93b07 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 26 Jan 2016 07:16:44 +0100 Subject: [PATCH] Revert "Cleanup code duplication in zip_file_decompressed" This reverts commit 173c9fd5ca848ceb1c164950f7b6989260bb733b. --- file_ops.c | 78 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 34 deletions(-) diff --git a/file_ops.c b/file_ops.c index dd1e8af7a5..cb8808c1eb 100644 --- a/file_ops.c +++ b/file_ops.c @@ -371,36 +371,6 @@ struct decomp_state * buf will be 0 then. */ -static bool zip_file_decompressed_handle(file_archive_file_handle_t *handle, - const uint8_t *cdata, uint32_t csize, uint32_t size, uint32_t crc32) -{ - int ret = 0; - - handle->backend = file_archive_get_default_file_backend(); - if (!handle->backend->stream_decompress_data_to_file_init( - handle, cdata, csize, size)) - return false; - - do{ - ret = handle->backend->stream_decompress_data_to_file_iterate( - handle->stream); - }while(ret == 0); - - handle->real_checksum = handle->backend->stream_crc_calculate(0, - handle->data, size); - - if (handle->real_checksum != crc32) - { - RARCH_ERR("Inflated checksum did not match CRC32!\n"); - return false; - } - - if (handle->stream) - free(handle->stream); - - return true; -} - static int zip_file_decompressed(const char *name, const char *valid_exts, const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size, uint32_t crc32, void *userdata) @@ -419,11 +389,33 @@ static int zip_file_decompressed(const char *name, const char *valid_exts, if (st->opt_file != 0) { /* Called in case core has need_fullpath enabled. */ + int ret = 0; file_archive_file_handle_t handle = {0}; char *buf = NULL; - zip_file_decompressed_handle(&handle, cdata, csize, size, - crc32); + + RARCH_LOG("opt file is: %s\n", st->opt_file); + handle.backend = file_archive_get_default_file_backend(); + if (!handle.backend->stream_decompress_data_to_file_init( + &handle, cdata, csize, size)) + return false; + + do{ + ret = handle.backend->stream_decompress_data_to_file_iterate( + handle.stream); + }while(ret == 0); + + handle.real_checksum = handle.backend->stream_crc_calculate(0, + handle.data, size); + + if (handle.real_checksum != crc32) + { + RARCH_ERR("Inflated checksum did not match CRC32!\n"); + goto error; + } + + if (handle.stream) + free(handle.stream); buf = malloc(size); if (!buf) @@ -448,11 +440,29 @@ static int zip_file_decompressed(const char *name, const char *valid_exts, /* Called in case core has need_fullpath disabled. * Will copy decompressed content directly into * RetroArch's ROM buffer. */ + int ret = 0; file_archive_file_handle_t handle = {0}; + handle.backend = file_archive_get_default_file_backend(); + if (!handle.backend->stream_decompress_data_to_file_init( + &handle, cdata, csize, size)) + return false; - zip_file_decompressed_handle(&handle, cdata, csize, size, - crc32); + do{ + ret = handle.backend->stream_decompress_data_to_file_iterate( + handle.stream); + }while(ret == 0); + handle.real_checksum = handle.backend->stream_crc_calculate(0, + handle.data, size); + + if (handle.real_checksum != crc32) + { + RARCH_ERR("Inflated checksum did not match CRC32!\n"); + goto error; + } + + if (handle.stream) + free(handle.stream); *st->buf = malloc(size); memcpy(*st->buf, handle.data, size);