Simplify zip_file_decompressed
This commit is contained in:
parent
b8212ec196
commit
adbaab9794
46
file_ops.c
46
file_ops.c
|
@ -427,19 +427,18 @@ static int zip_file_decompressed(const char *name, const char *valid_exts,
|
||||||
|
|
||||||
if (strstr(name, st->needle))
|
if (strstr(name, st->needle))
|
||||||
{
|
{
|
||||||
|
bool goto_error = false;
|
||||||
|
file_archive_file_handle_t handle = {0};
|
||||||
|
|
||||||
st->found = true;
|
st->found = true;
|
||||||
|
|
||||||
if (st->opt_file != 0)
|
if (zip_file_decompressed_handle(&handle,
|
||||||
|
cdata, csize, size, crc32))
|
||||||
{
|
{
|
||||||
/* Called in case core has need_fullpath enabled. */
|
if (st->opt_file != 0)
|
||||||
file_archive_file_handle_t handle = {0};
|
|
||||||
char *buf = NULL;
|
|
||||||
|
|
||||||
if (zip_file_decompressed_handle(&handle,
|
|
||||||
cdata, csize, size, crc32))
|
|
||||||
{
|
{
|
||||||
bool goto_error = false;
|
/* Called in case core has need_fullpath enabled. */
|
||||||
buf = (char*)malloc(size);
|
char *buf = (char*)malloc(size);
|
||||||
|
|
||||||
if (buf)
|
if (buf)
|
||||||
{
|
{
|
||||||
|
@ -448,35 +447,28 @@ static int zip_file_decompressed(const char *name, const char *valid_exts,
|
||||||
goto_error = true;
|
goto_error = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handle.data)
|
|
||||||
free(handle.data);
|
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
if (goto_error)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
st->size = 0;
|
st->size = 0;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Called in case core has need_fullpath disabled.
|
|
||||||
* Will copy decompressed content directly into
|
|
||||||
* RetroArch's ROM buffer. */
|
|
||||||
file_archive_file_handle_t handle = {0};
|
|
||||||
|
|
||||||
if (zip_file_decompressed_handle(&handle,
|
|
||||||
cdata, csize, size, crc32))
|
|
||||||
{
|
{
|
||||||
|
/* Called in case core has need_fullpath disabled.
|
||||||
|
* Will copy decompressed content directly into
|
||||||
|
* RetroArch's ROM buffer. */
|
||||||
*st->buf = malloc(size);
|
*st->buf = malloc(size);
|
||||||
memcpy(*st->buf, handle.data, size);
|
memcpy(*st->buf, handle.data, size);
|
||||||
|
|
||||||
if (handle.data)
|
|
||||||
free(handle.data);
|
|
||||||
|
|
||||||
st->size = size;
|
st->size = size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (handle.data)
|
||||||
|
free(handle.data);
|
||||||
|
|
||||||
|
if (goto_error)
|
||||||
|
goto error;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
next_file:
|
next_file:
|
||||||
|
|
Loading…
Reference in New Issue