mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 11:43:00 +00:00
Start adding ways to extract only one file from a ZIP
This commit is contained in:
parent
a3ae0e9a90
commit
9256cd2fbc
@ -459,7 +459,7 @@ void cb_generic_download(void *task_data, void *user_data, const char *err)
|
||||
|
||||
if (string_is_equal_noncase(file_ext, "zip"))
|
||||
{
|
||||
rarch_task_push_decompress(output_path, dir_path, NULL, NULL,
|
||||
rarch_task_push_decompress(output_path, dir_path, NULL, NULL, NULL,
|
||||
cb_decompressed, (void*)(uintptr_t)transf->type_hash);
|
||||
}
|
||||
#else
|
||||
|
@ -622,7 +622,7 @@ void *menu_init(const void *data)
|
||||
menu->push_help_screen = true;
|
||||
#ifdef HAVE_ZLIB
|
||||
rarch_task_push_decompress(settings->bundle_assets_src_path, settings->bundle_assets_dst_path,
|
||||
settings->bundle_assets_dst_path_subdir, NULL, bundle_decompressed, NULL);
|
||||
settings->bundle_assets_dst_path_subdir, NULL, NULL, bundle_decompressed, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ typedef struct
|
||||
char *source_file;
|
||||
char *subdir;
|
||||
char *target_dir;
|
||||
char *target_file;
|
||||
char *valid_ext;
|
||||
|
||||
char *callback_error;
|
||||
@ -39,6 +40,14 @@ typedef struct
|
||||
zlib_transfer_t zlib;
|
||||
} decompress_state_t;
|
||||
|
||||
static int file_decompressed_target_file(const char *name, const char *valid_exts,
|
||||
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
||||
uint32_t crc32, void *userdata)
|
||||
{
|
||||
/* TODO/FIXME */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int file_decompressed_subdir(const char *name, const char *valid_exts,
|
||||
const uint8_t *cdata, unsigned cmode, uint32_t csize, uint32_t size,
|
||||
uint32_t crc32, void *userdata)
|
||||
@ -161,6 +170,24 @@ static void rarch_task_decompress_handler(rarch_task_t *task)
|
||||
}
|
||||
}
|
||||
|
||||
static void rarch_task_decompress_handler_target_file(rarch_task_t *task)
|
||||
{
|
||||
bool returnerr;
|
||||
decompress_state_t *dec = (decompress_state_t*)task->state;
|
||||
int ret = zlib_parse_file_iterate(&dec->zlib, &returnerr, dec->source_file,
|
||||
dec->valid_ext, file_decompressed_target_file, dec);
|
||||
|
||||
task->progress = zlib_parse_file_progress(&dec->zlib);
|
||||
|
||||
if (task->cancelled || ret != 0)
|
||||
{
|
||||
task->error = dec->callback_error;
|
||||
zlib_parse_file_iterate_stop(&dec->zlib);
|
||||
|
||||
rarch_task_decompress_handler_finished(task, dec);
|
||||
}
|
||||
}
|
||||
|
||||
static void rarch_task_decompress_handler_subdir(rarch_task_t *task)
|
||||
{
|
||||
bool returnerr;
|
||||
@ -189,8 +216,14 @@ static bool rarch_task_decompress_finder(rarch_task_t *task, void *user_data)
|
||||
return string_is_equal(dec->source_file, (const char*)user_data);
|
||||
}
|
||||
|
||||
bool rarch_task_push_decompress(const char *source_file, const char *target_dir,
|
||||
const char *subdir, const char *valid_ext, rarch_task_callback_t cb, void *user_data)
|
||||
bool rarch_task_push_decompress(
|
||||
const char *source_file,
|
||||
const char *target_dir,
|
||||
const char *target_file,
|
||||
const char *subdir,
|
||||
const char *valid_ext,
|
||||
rarch_task_callback_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
char tmp[PATH_MAX_LENGTH];
|
||||
decompress_state_t *s = NULL;
|
||||
@ -246,8 +279,13 @@ bool rarch_task_push_decompress(const char *source_file, const char *target_dir,
|
||||
|
||||
if (!string_is_empty(subdir))
|
||||
{
|
||||
s->subdir = strdup(subdir);
|
||||
t->handler = rarch_task_decompress_handler_subdir;
|
||||
s->subdir = strdup(subdir);
|
||||
t->handler = rarch_task_decompress_handler_subdir;
|
||||
}
|
||||
else if (!string_is_empty(target_file))
|
||||
{
|
||||
s->target_file = strdup(subdir);
|
||||
t->handler = rarch_task_decompress_handler_target_file;
|
||||
}
|
||||
|
||||
t->callback = cb;
|
||||
|
@ -158,8 +158,12 @@ typedef struct {
|
||||
char *source_file;
|
||||
} decompress_task_data_t;
|
||||
|
||||
bool rarch_task_push_decompress(const char *source_file, const char *target_dir,
|
||||
const char *subdir, const char *valid_ext,
|
||||
bool rarch_task_push_decompress(
|
||||
const char *source_file,
|
||||
const char *target_dir,
|
||||
const char *target_file,
|
||||
const char *subdir,
|
||||
const char *valid_ext,
|
||||
rarch_task_callback_t cb, void *user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
Loading…
x
Reference in New Issue
Block a user