mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
(archive_file.c) Cleanups/style nits
This commit is contained in:
parent
1ddd0ab1d3
commit
6935ce902e
@ -213,6 +213,7 @@ static int file_archive_get_file_list_cb(
|
|||||||
|
|
||||||
if (!string_list_find_elem_prefix(ext_list, ".", file_ext))
|
if (!string_list_find_elem_prefix(ext_list, ".", file_ext))
|
||||||
{
|
{
|
||||||
|
/* keep iterating */
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -301,9 +302,9 @@ static int file_archive_parse_file_init(file_archive_transfer_t *state,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
state->archive_size = file_archive_size(state->handle);
|
state->archive_size = file_archive_size(state->handle);
|
||||||
state->data = file_archive_data(state->handle);
|
state->data = file_archive_data(state->handle);
|
||||||
state->footer = 0;
|
state->footer = 0;
|
||||||
state->directory = 0;
|
state->directory = 0;
|
||||||
|
|
||||||
return state->backend->archive_parse_file_init(state, path);
|
return state->backend->archive_parse_file_init(state, path);
|
||||||
}
|
}
|
||||||
@ -402,7 +403,8 @@ int file_archive_parse_file_iterate(
|
|||||||
if (userdata)
|
if (userdata)
|
||||||
{
|
{
|
||||||
userdata->context = state->stream;
|
userdata->context = state->stream;
|
||||||
strlcpy(userdata->archive_path, file, sizeof(userdata->archive_path));
|
strlcpy(userdata->archive_path, file,
|
||||||
|
sizeof(userdata->archive_path));
|
||||||
}
|
}
|
||||||
state->type = ARCHIVE_TRANSFER_ITERATE;
|
state->type = ARCHIVE_TRANSFER_ITERATE;
|
||||||
}
|
}
|
||||||
@ -414,8 +416,10 @@ int file_archive_parse_file_iterate(
|
|||||||
{
|
{
|
||||||
const struct file_archive_file_backend *backend =
|
const struct file_archive_file_backend *backend =
|
||||||
file_archive_get_file_backend(file);
|
file_archive_get_file_backend(file);
|
||||||
int ret = backend->archive_parse_file_iterate_step(state,
|
int ret =
|
||||||
|
backend->archive_parse_file_iterate_step(state,
|
||||||
valid_exts, userdata, file_cb);
|
valid_exts, userdata, file_cb);
|
||||||
|
|
||||||
if (ret != 1)
|
if (ret != 1)
|
||||||
state->type = ARCHIVE_TRANSFER_DEINIT;
|
state->type = ARCHIVE_TRANSFER_DEINIT;
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
@ -433,6 +437,7 @@ int file_archive_parse_file_iterate(
|
|||||||
file_archive_free(state->handle);
|
file_archive_free(state->handle);
|
||||||
state->handle = NULL;
|
state->handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->stream && state->backend)
|
if (state->stream && state->backend)
|
||||||
{
|
{
|
||||||
if (state->backend->stream_free)
|
if (state->backend->stream_free)
|
||||||
@ -449,7 +454,7 @@ int file_archive_parse_file_iterate(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->type == ARCHIVE_TRANSFER_DEINIT ||
|
if ( state->type == ARCHIVE_TRANSFER_DEINIT ||
|
||||||
state->type == ARCHIVE_TRANSFER_DEINIT_ERROR)
|
state->type == ARCHIVE_TRANSFER_DEINIT_ERROR)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -473,7 +478,7 @@ static bool file_archive_walk(const char *file, const char *valid_exts,
|
|||||||
file_archive_file_cb file_cb, struct archive_extract_userdata *userdata)
|
file_archive_file_cb file_cb, struct archive_extract_userdata *userdata)
|
||||||
{
|
{
|
||||||
file_archive_transfer_t state = {0};
|
file_archive_transfer_t state = {0};
|
||||||
bool returnerr = true;
|
bool returnerr = true;
|
||||||
|
|
||||||
state.type = ARCHIVE_TRANSFER_INIT;
|
state.type = ARCHIVE_TRANSFER_INIT;
|
||||||
|
|
||||||
@ -621,14 +626,18 @@ bool file_archive_perform_mode(const char *path, const char *valid_exts,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
file_archive_file_handle_t handle = {0};
|
file_archive_file_handle_t handle = {0};
|
||||||
|
|
||||||
handle.backend = file_archive_get_file_backend(userdata->archive_path);
|
handle.backend = file_archive_get_file_backend(userdata->archive_path);
|
||||||
handle.stream = userdata->context;
|
handle.stream = userdata->context;
|
||||||
|
|
||||||
if (!handle.backend || !handle.backend->stream_decompress_data_to_file_init(&handle,
|
if (!handle.backend)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
if (!handle.backend->stream_decompress_data_to_file_init(&handle,
|
||||||
cdata, csize, size))
|
cdata, csize, size))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
do{
|
do
|
||||||
|
{
|
||||||
ret = handle.backend->stream_decompress_data_to_file_iterate(
|
ret = handle.backend->stream_decompress_data_to_file_iterate(
|
||||||
handle.stream);
|
handle.stream);
|
||||||
}while(ret == 0);
|
}while(ret == 0);
|
||||||
@ -661,12 +670,10 @@ static struct string_list *file_archive_filename_split(const char *path)
|
|||||||
{
|
{
|
||||||
union string_list_elem_attr attr;
|
union string_list_elem_attr attr;
|
||||||
struct string_list *list = string_list_new();
|
struct string_list *list = string_list_new();
|
||||||
const char *delim = NULL;
|
const char *delim = path_get_archive_delim(path);
|
||||||
|
|
||||||
memset(&attr, 0, sizeof(attr));
|
memset(&attr, 0, sizeof(attr));
|
||||||
|
|
||||||
delim = path_get_archive_delim(path);
|
|
||||||
|
|
||||||
if (delim)
|
if (delim)
|
||||||
{
|
{
|
||||||
/* add archive path to list first */
|
/* add archive path to list first */
|
||||||
@ -786,8 +793,9 @@ const struct file_archive_file_backend* file_archive_get_file_backend(const char
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_ZLIB
|
#ifdef HAVE_ZLIB
|
||||||
if (string_is_equal_noncase(file_ext, "zip") ||
|
if ( string_is_equal_noncase(file_ext, "zip")
|
||||||
string_is_equal_noncase(file_ext, "apk"))
|
|| string_is_equal_noncase(file_ext, "apk")
|
||||||
|
)
|
||||||
return &zlib_backend;
|
return &zlib_backend;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user