diff --git a/libretro-common/file/archive_file.c b/libretro-common/file/archive_file.c index b1fa2873c2..2aeeb6bee3 100644 --- a/libretro-common/file/archive_file.c +++ b/libretro-common/file/archive_file.c @@ -560,6 +560,7 @@ struct string_list *file_archive_get_file_list(const char *path, { struct archive_extract_userdata userdata = {0}; userdata.list_only = true; + userdata.archive_path = strdup(path); userdata.list = string_list_new(); @@ -570,9 +571,20 @@ struct string_list *file_archive_get_file_list(const char *path, file_archive_get_file_list_cb, &userdata)) goto error; + if (userdata.archive_path) + { + free(userdata.archive_path); + userdata.archive_path = NULL; + } + return userdata.list; error: + if (userdata.archive_path) + { + free(userdata.archive_path); + userdata.archive_path = NULL; + } if (userdata.list) string_list_free(userdata.list); return NULL; @@ -769,7 +781,8 @@ const struct file_archive_file_backend* file_archive_get_file_backend(const char #endif #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")) return &zlib_backend; #endif diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 7f99e489d8..92f715635c 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -104,8 +104,13 @@ const char *path_get_archive_delim(const char *path) #ifdef HAVE_ZLIB if (last) + { delim = strcasestr(last, ".zip#"); + if (!delim) + delim = strcasestr(last, ".apk#"); + } + if (delim) return delim + 4; #endif @@ -194,7 +199,8 @@ bool path_is_compressed_file(const char* path) const char *ext = path_get_extension(path); #ifdef HAVE_ZLIB - if (string_is_equal_noncase(ext, "zip")) + if (string_is_equal_noncase(ext, "zip") || + string_is_equal_noncase(ext, "apk")) return true; #endif @@ -482,7 +488,7 @@ void path_basedir(char *path) return; #ifdef HAVE_COMPRESSION - /* We want to find the directory with the zipfile in basedir. */ + /* We want to find the directory with the archive in basedir. */ last = (char*)path_get_archive_delim(path); if (last) *last = '\0'; diff --git a/libretro-common/include/file/archive_file.h b/libretro-common/include/file/archive_file.h index 296ef467cf..b4a38ea505 100644 --- a/libretro-common/include/file/archive_file.h +++ b/libretro-common/include/file/archive_file.h @@ -156,18 +156,18 @@ int file_archive_parse_file_progress(file_archive_transfer_t *state); /** * file_archive_extract_file: - * @zip_path : filename path to ZIP archive. - * @zip_path_size : size of ZIP archive. + * @archive_path : filename path to ZIP archive. + * @archive_path_size : size of ZIP archive. * @valid_exts : valid extensions for a file. - * @extraction_directory : the directory to extract temporary - * unzipped file to. + * @extraction_directory : the directory to extract the temporary + * file to. * * Extract file from archive. If no file inside the archive is * specified, the first file found will be used. * * Returns : true (1) on success, otherwise false (0). **/ -bool file_archive_extract_file(char *zip_path, size_t zip_path_size, +bool file_archive_extract_file(char *archive_path, size_t archive_path_size, const char *valid_exts, const char *extraction_dir, char *out_path, size_t len); diff --git a/tasks/task_database.c b/tasks/task_database.c index 3c3c11378a..ca58a6fab2 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -345,7 +345,7 @@ static int database_info_list_iterate_next( static int task_database_iterate_crc_lookup( database_state_handle_t *db_state, database_info_handle_t *db, - const char *zip_entry) + const char *archive_entry) { if (!db_state->list || @@ -378,7 +378,7 @@ static int task_database_iterate_crc_lookup( db_state, db, NULL); if (db_state->crc == db_info_entry->crc32) return database_info_list_iterate_found_match( - db_state, db, zip_entry); + db_state, db, archive_entry); } }