Fix zlib_extract_first_content_file - we now pass a

new string to zlib_extract_first_content_file which will
fill in the extracted first file's path, we then add this
to temporary_content string list
This commit is contained in:
twinaphex 2016-01-24 05:41:41 +01:00
parent f4dfde8c47
commit 458e3a0fad
3 changed files with 18 additions and 6 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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: