mirror of
https://github.com/libretro/RetroArch
synced 2025-02-07 03:40:24 +00:00
commit
b1d3ecf8b7
@ -1150,7 +1150,9 @@ endif
|
||||
|
||||
ifeq ($(HAVE_COMPRESSION), 1)
|
||||
DEFINES += -DHAVE_COMPRESSION
|
||||
OBJ += tasks/task_decompress.o
|
||||
OBJ += libretro-common/file/archive_file.o \
|
||||
libretro-common/encodings/encoding_crc32.o \
|
||||
tasks/task_decompress.o
|
||||
endif
|
||||
|
||||
#ifeq ($(HAVE_DIRECTX), 1)
|
||||
|
@ -321,11 +321,11 @@ static int file_archive_decompress_data_to_file(
|
||||
goto end;
|
||||
}
|
||||
|
||||
handle->real_checksum = handle->backend->stream_crc_calculate(
|
||||
0, handle->data, size);
|
||||
handle->backend->stream_free(handle->stream);
|
||||
|
||||
#if 0
|
||||
handle->real_checksum = handle->backend->stream_crc_calculate(
|
||||
0, handle->data, size);
|
||||
if (handle->real_checksum != checksum)
|
||||
{
|
||||
/* File CRC difers from archive CRC. */
|
||||
@ -671,16 +671,10 @@ struct string_list *file_archive_file_list_new(const char *path,
|
||||
const char* ext)
|
||||
{
|
||||
#ifdef HAVE_COMPRESSION
|
||||
const char* file_ext = path_get_extension(path);
|
||||
bool compressed = path_is_compressed_file(path);
|
||||
|
||||
#ifdef HAVE_7ZIP
|
||||
if (string_is_equal_noncase(file_ext, "7z"))
|
||||
if (compressed)
|
||||
return file_archive_get_file_list(path, ext);
|
||||
#endif
|
||||
#ifdef HAVE_ZLIB
|
||||
if (string_is_equal_noncase(file_ext, "zip"))
|
||||
return file_archive_get_file_list(path, ext);
|
||||
#endif
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <streams/file_stream.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <encodings/utf.h>
|
||||
#include <encodings/crc32.h>
|
||||
#include <string/stdstring.h>
|
||||
#include <lists/string_list.h>
|
||||
#include <file/file_path.h>
|
||||
@ -328,7 +329,7 @@ static int sevenzip_parse_file_iterate_step_internal(
|
||||
if (res != SZ_OK)
|
||||
return -1;
|
||||
|
||||
strlcpy(filename, infile, sizeof(infile));
|
||||
strlcpy(filename, infile, PATH_MAX_LENGTH);
|
||||
|
||||
*cmode = ARCHIVE_MODE_COMPRESSED;
|
||||
*checksum = file->Crc;
|
||||
@ -374,7 +375,7 @@ static int sevenzip_parse_file_iterate_step(file_archive_transfer_t *state,
|
||||
static uint32_t sevenzip_stream_crc32_calculate(uint32_t crc,
|
||||
const uint8_t *data, size_t length)
|
||||
{
|
||||
return CrcUpdate(crc, data, length);
|
||||
return encoding_crc32(crc, data, length);
|
||||
}
|
||||
|
||||
const struct file_archive_file_backend sevenzip_backend = {
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <streams/file_stream.h>
|
||||
#include <string.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <encodings/crc32.h>
|
||||
|
||||
#ifndef CENTRAL_FILE_HEADER_SIGNATURE
|
||||
#define CENTRAL_FILE_HEADER_SIGNATURE 0x02014b50
|
||||
@ -204,7 +205,7 @@ static void zlib_stream_compress_init(void *data, int level)
|
||||
static uint32_t zlib_stream_crc32_calculate(uint32_t crc,
|
||||
const uint8_t *data, size_t length)
|
||||
{
|
||||
return crc32(crc, data, length);
|
||||
return encoding_crc32(crc, data, length);
|
||||
}
|
||||
|
||||
struct decomp_state
|
||||
@ -233,18 +234,19 @@ static bool zip_file_decompressed_handle(
|
||||
ret = handle->backend->stream_decompress_data_to_file_iterate(
|
||||
handle->stream);
|
||||
}while(ret == 0);
|
||||
|
||||
#if 0
|
||||
handle->real_checksum = handle->backend->stream_crc_calculate(0,
|
||||
handle->data, size);
|
||||
|
||||
if (handle->real_checksum != crc32)
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
if (handle->stream)
|
||||
free(handle->stream);
|
||||
|
||||
return true;
|
||||
|
||||
#if 0
|
||||
error:
|
||||
if (handle->stream)
|
||||
free(handle->stream);
|
||||
@ -253,8 +255,8 @@ error:
|
||||
|
||||
handle->stream = NULL;
|
||||
handle->data = NULL;
|
||||
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Extract the relative path (needle) from a
|
||||
|
@ -44,7 +44,7 @@ struct string_list_elem
|
||||
union string_list_elem_attr attr;
|
||||
};
|
||||
|
||||
struct __attribute__ ((aligned(1))) string_list
|
||||
struct string_list
|
||||
{
|
||||
struct string_list_elem *elems;
|
||||
size_t size;
|
||||
|
@ -104,7 +104,6 @@ typedef struct content_stream
|
||||
uint32_t crc;
|
||||
} content_stream_t;
|
||||
|
||||
static const struct file_archive_file_backend *stream_backend = NULL;
|
||||
static struct string_list *temporary_content = NULL;
|
||||
static bool _content_is_inited = false;
|
||||
static bool core_does_not_need_content = false;
|
||||
@ -125,7 +124,7 @@ static uint32_t content_crc = 0;
|
||||
static int content_file_read(const char *path, void **buf, ssize_t *length)
|
||||
{
|
||||
#ifdef HAVE_COMPRESSION
|
||||
if (path_contains_compressed_file(path))
|
||||
if (path_is_compressed_file(path))
|
||||
{
|
||||
if (file_archive_compressed_read(path, buf, NULL, length))
|
||||
return 1;
|
||||
@ -389,7 +388,7 @@ error:
|
||||
static bool read_content_file(unsigned i, const char *path, void **buf,
|
||||
ssize_t *length)
|
||||
{
|
||||
#ifdef HAVE_ZLIB
|
||||
#ifdef HAVE_COMPRESSION
|
||||
content_stream_t stream_info;
|
||||
uint32_t *content_crc_ptr = NULL;
|
||||
#endif
|
||||
@ -411,20 +410,25 @@ static bool read_content_file(unsigned i, const char *path, void **buf,
|
||||
if (!global->patch.block_patch)
|
||||
patch_content(&ret_buf, length);
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
#ifdef HAVE_COMPRESSION
|
||||
content_get_crc(&content_crc_ptr);
|
||||
|
||||
stream_info.a = 0;
|
||||
stream_info.b = ret_buf;
|
||||
stream_info.c = *length;
|
||||
|
||||
if (!stream_backend)
|
||||
stream_backend = file_archive_get_zlib_file_backend();
|
||||
stream_info.crc = stream_backend->stream_crc_calculate(
|
||||
stream_info.a, stream_info.b, stream_info.c);
|
||||
*content_crc_ptr = stream_info.crc;
|
||||
const struct file_archive_file_backend *stream_backend =
|
||||
file_archive_get_file_backend(path);
|
||||
|
||||
RARCH_LOG("CRC32: 0x%x .\n", (unsigned)*content_crc_ptr);
|
||||
if (stream_backend)
|
||||
{
|
||||
stream_info.crc = stream_backend->stream_crc_calculate(
|
||||
stream_info.a, stream_info.b, stream_info.c);
|
||||
|
||||
*content_crc_ptr = stream_info.crc;
|
||||
|
||||
RARCH_LOG("CRC32: 0x%x .\n", (unsigned)*content_crc_ptr);
|
||||
}
|
||||
#endif
|
||||
*buf = ret_buf;
|
||||
|
||||
|
@ -63,8 +63,8 @@ typedef struct db_handle
|
||||
|
||||
#ifdef HAVE_LIBRETRODB
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
static int zlib_compare_crc32(const char *name, const char *valid_exts,
|
||||
#ifdef HAVE_COMPRESSION
|
||||
static int archive_compare_crc32(const char *name, const char *valid_exts,
|
||||
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
||||
uint32_t crc32, void *userdata)
|
||||
{
|
||||
@ -166,17 +166,19 @@ static bool file_get_crc(database_state_handle_t *db_state,
|
||||
int read_from = filestream_read_file(
|
||||
name, (void**)&db_state->buf, &ret);
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
const struct file_archive_file_backend *stream_backend =
|
||||
file_archive_get_zlib_file_backend();
|
||||
#endif
|
||||
|
||||
if (read_from != 1 || ret <= 0)
|
||||
return 0;
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
*crc = stream_backend->stream_crc_calculate(
|
||||
0, db_state->buf, ret);
|
||||
#ifdef HAVE_COMPRESSION
|
||||
if(!path_is_compressed_file(name))
|
||||
{
|
||||
const struct file_archive_file_backend *stream_backend =
|
||||
file_archive_get_file_backend(name);
|
||||
|
||||
if (stream_backend)
|
||||
*crc = stream_backend->stream_crc_calculate(
|
||||
0, db_state->buf, ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
@ -409,13 +411,13 @@ static int task_database_iterate_playlist_archive(
|
||||
database_info_handle_t *db, const char *name)
|
||||
{
|
||||
bool returnerr = true;
|
||||
#ifdef HAVE_ZLIB
|
||||
#ifdef HAVE_COMPRESSION
|
||||
if (db_state->crc != 0)
|
||||
return task_database_iterate_crc_lookup(
|
||||
db_state, db, db_state->archive_name);
|
||||
|
||||
if (file_archive_parse_file_iterate(&db->state,
|
||||
&returnerr, name, NULL, zlib_compare_crc32,
|
||||
&returnerr, name, NULL, archive_compare_crc32,
|
||||
(void*)db_state) != 0)
|
||||
return 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user