mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-12 12:39:56 +00:00
(task_decompress.c) Add progress report
This commit is contained in:
parent
cf0a493605
commit
a171f3c6d1
@ -604,6 +604,15 @@ bool zlib_parse_file(const char *file, const char *valid_exts,
|
||||
return returnerr;
|
||||
}
|
||||
|
||||
int zlib_parse_file_progress(void *data)
|
||||
{
|
||||
/* FIXME: this estimate is pretty bad */
|
||||
zlib_transfer_t *state = (zlib_transfer_t*)data;
|
||||
const uint8_t *offset = state->data + read_le(state->directory + 42, 4);
|
||||
ptrdiff_t delta = offset - state->data - 46 - 22;
|
||||
return delta * 100 / state->zip_size;
|
||||
}
|
||||
|
||||
struct zip_extract_userdata
|
||||
{
|
||||
char *zip_path;
|
||||
|
@ -86,6 +86,8 @@ int zlib_parse_file_iterate(void *data, bool *returnerr,
|
||||
|
||||
void zlib_parse_file_iterate_stop(void *data);
|
||||
|
||||
int zlib_parse_file_progress(void *data);
|
||||
|
||||
/**
|
||||
* zlib_extract_first_content_file:
|
||||
* @zip_path : filename path to ZIP archive.
|
||||
|
@ -81,6 +81,8 @@ static void rarch_task_decompress_handler(rarch_task_t *task)
|
||||
ret = zlib_parse_file_iterate(&dec->zlib, &returnerr, dec->source_file,
|
||||
dec->valid_ext, file_decompressed, dec);
|
||||
|
||||
task->progress = zlib_parse_file_progress(&dec->zlib);
|
||||
|
||||
if (task->cancelled || ret != 0)
|
||||
{
|
||||
task->error = dec->callback_error;
|
||||
|
Loading…
x
Reference in New Issue
Block a user