diff --git a/content.c b/content.c index 5de4cbbc51..784b173a9a 100644 --- a/content.c +++ b/content.c @@ -606,6 +606,7 @@ static bool init_content_file_extract( if (string_is_equal_noncase(ext, "zip")) { + char new_path[PATH_MAX_LENGTH]; char temp_content[PATH_MAX_LENGTH]; strlcpy(temp_content, content->elems[i].data, @@ -614,16 +615,17 @@ static bool init_content_file_extract( if (!zlib_extract_first_content_file(temp_content, sizeof(temp_content), valid_ext, *settings->cache_directory ? - settings->cache_directory : NULL)) + settings->cache_directory : NULL, + new_path, sizeof(new_path))) { RARCH_ERR("Failed to extract content from zipped file: %s.\n", temp_content); return false; } - string_list_set(content, i, temp_content); + string_list_set(content, i, new_path); if (!string_list_append(temporary_content, - temp_content, *attr)) + new_path, *attr)) return false; } } diff --git a/libretro-common/file/file_extract.c b/libretro-common/file/file_extract.c index 8458cfba9d..6249069858 100644 --- a/libretro-common/file/file_extract.c +++ b/libretro-common/file/file_extract.c @@ -615,6 +615,7 @@ int zlib_parse_file_progress(void *data) struct zip_extract_userdata { char *zip_path; + char *first_extracted_file_path; const char *extraction_directory; size_t zip_path_size; struct string_list *ext; @@ -648,7 +649,9 @@ static int zip_extract_cb(const char *name, const char *valid_exts, fill_pathname_resolve_relative(new_path, data->zip_path, path_basename(name), sizeof(new_path)); - data->found_content = zlib_perform_mode(new_path, valid_exts, cdata, cmode, csize, size, + data->first_extracted_file_path = strdup(new_path); + data->found_content = zlib_perform_mode(new_path, + valid_exts, cdata, cmode, csize, size, 0, NULL); return 0; } @@ -669,7 +672,8 @@ static int zip_extract_cb(const char *name, const char *valid_exts, * Returns : true (1) on success, otherwise false (0). **/ bool zlib_extract_first_content_file(char *zip_path, size_t zip_path_size, - const char *valid_exts, const char *extraction_directory) + const char *valid_exts, const char *extraction_directory, + char *out_path, size_t len) { struct string_list *list; bool ret = true; @@ -704,7 +708,12 @@ bool zlib_extract_first_content_file(char *zip_path, size_t zip_path_size, GOTO_END_ERROR(); } + if (*userdata.first_extracted_file_path) + strlcpy(out_path, userdata.first_extracted_file_path, len); + end: + if (userdata.first_extracted_file_path) + free(userdata.first_extracted_file_path); if (list) string_list_free(list); return ret; diff --git a/libretro-common/include/file/file_extract.h b/libretro-common/include/file/file_extract.h index 6c1ae44f6d..9fdeb8c84d 100644 --- a/libretro-common/include/file/file_extract.h +++ b/libretro-common/include/file/file_extract.h @@ -101,7 +101,8 @@ int zlib_parse_file_progress(void *data); * Returns : true (1) on success, otherwise false (0). **/ bool zlib_extract_first_content_file(char *zip_path, size_t zip_path_size, - const char *valid_exts, const char *extraction_dir); + const char *valid_exts, const char *extraction_dir, + char *out_path, size_t len); /** * zlib_get_file_list: