mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-25 00:49:47 +00:00
Create zlib_perform_mode
This commit is contained in:
parent
104904fc97
commit
9281595024
@ -5,7 +5,7 @@ LOCAL_MODULE := retroarch-jni
|
||||
RARCH_DIR := ../../..
|
||||
LOCAL_CFLAGS += -std=gnu99 -Wall -DHAVE_LOGGER -DRARCH_DUMMY_LOG -DHAVE_ZLIB -DHAVE_MMAP -DRARCH_INTERNAL
|
||||
LOCAL_LDLIBS := -llog -lz
|
||||
LOCAL_SRC_FILES := apk-extract/apk-extract.c $(RARCH_DIR)/file_extract.c $(RARCH_DIR)/libretro-common/file/file_path.c $(RARCH_DIR)/file_ops.c $(RARCH_DIR)/libretro-common/string/string_list.c $(RARCH_DIR)/libretro-common/compat/compat.c
|
||||
LOCAL_SRC_FILES := apk-extract/apk-extract.c $(RARCH_DIR)/libretro-common/file/file_extract.c $(RARCH_DIR)/libretro-common/file/file_path.c $(RARCH_DIR)/file_ops.c $(RARCH_DIR)/libretro-common/string/string_list.c $(RARCH_DIR)/libretro-common/compat/compat.c
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(RARCH_DIR)/libretro-common/include/
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "../../../../file_extract.h"
|
||||
#include "../../../../file_ops.h"
|
||||
#include <file/file_extract.h>
|
||||
#include <file/file_path.h>
|
||||
|
||||
#include <stdio.h>
|
||||
@ -47,35 +46,15 @@ static int zlib_cb(const char *name, const char *valid_exts,
|
||||
|
||||
RARCH_LOG("Extracting %s -> %s ...\n", name, path);
|
||||
|
||||
switch (cmode)
|
||||
if (!zlib_perform_mode(path, valid_exts,
|
||||
cdata, cmode, csize, size, crc32, userdata))
|
||||
{
|
||||
case 0: /* Uncompressed */
|
||||
if (!write_file(path, cdata, size))
|
||||
{
|
||||
RARCH_ERR("Failed to write file: %s.\n", path);
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case 8: /* Deflate */
|
||||
{
|
||||
int ret = 0;
|
||||
zlib_file_handle_t handle = {0};
|
||||
if (!zlib_inflate_data_to_file_init(&handle, cdata, csize, size))
|
||||
goto error;
|
||||
|
||||
do{
|
||||
ret = zlib_inflate_data_to_file_iterate(handle.stream);
|
||||
}while(ret == 0);
|
||||
|
||||
if (!zlib_inflate_data_to_file(&handle, ret, path, valid_exts,
|
||||
cdata, csize, size, crc32))
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (cmode == 0)
|
||||
{
|
||||
RARCH_ERR("Failed to write file: %s.\n", path);
|
||||
return 0;
|
||||
}
|
||||
goto error;
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -727,3 +727,37 @@ struct string_list *zlib_get_file_list(const char *path, const char *valid_exts)
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
bool zlib_perform_mode(const char *path, const char *valid_exts,
|
||||
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
||||
uint32_t crc32, void *userdata)
|
||||
{
|
||||
switch (cmode)
|
||||
{
|
||||
case 0: /* Uncompressed */
|
||||
if (!zlib_write_file(path, cdata, size))
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 8: /* Deflate */
|
||||
{
|
||||
int ret = 0;
|
||||
zlib_file_handle_t handle = {0};
|
||||
if (!zlib_inflate_data_to_file_init(&handle, cdata, csize, size))
|
||||
return false;
|
||||
|
||||
do{
|
||||
ret = zlib_inflate_data_to_file_iterate(handle.stream);
|
||||
}while(ret == 0);
|
||||
|
||||
if (!zlib_inflate_data_to_file(&handle, ret, path, valid_exts,
|
||||
cdata, csize, size, crc32))
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -106,6 +106,10 @@ int zlib_inflate_data_to_file(zlib_file_handle_t *handle,
|
||||
int ret, const char *path, const char *valid_exts,
|
||||
const uint8_t *cdata, uint32_t csize, uint32_t size, uint32_t checksum);
|
||||
|
||||
bool zlib_perform_mode(const char *name, const char *valid_exts,
|
||||
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
||||
uint32_t crc32, void *userdata);
|
||||
|
||||
struct string_list *compressed_file_list_new(const char *filename,
|
||||
const char* ext);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user