mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-06 11:38:23 +00:00
Add support for ZIP extraction to temporary folders.
This commit is contained in:
parent
9f5a714615
commit
2280e28737
3
file.c
3
file.c
@ -462,7 +462,8 @@ bool init_rom_file(void)
|
|||||||
{
|
{
|
||||||
char temporary_rom[PATH_MAX];
|
char temporary_rom[PATH_MAX];
|
||||||
strlcpy(temporary_rom, roms->elems[i].data, sizeof(temporary_rom));
|
strlcpy(temporary_rom, roms->elems[i].data, sizeof(temporary_rom));
|
||||||
if (!zlib_extract_first_rom(temporary_rom, sizeof(temporary_rom), valid_ext))
|
if (!zlib_extract_first_rom(temporary_rom, sizeof(temporary_rom), valid_ext,
|
||||||
|
*g_settings.extraction_directory ? g_settings.extraction_directory : NULL))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to extract ROM from zipped file: %s.\n", temporary_rom);
|
RARCH_ERR("Failed to extract ROM from zipped file: %s.\n", temporary_rom);
|
||||||
string_list_free(roms);
|
string_list_free(roms);
|
||||||
|
@ -308,6 +308,7 @@ end:
|
|||||||
struct zip_extract_userdata
|
struct zip_extract_userdata
|
||||||
{
|
{
|
||||||
char *zip_path;
|
char *zip_path;
|
||||||
|
const char *extraction_directory;
|
||||||
size_t zip_path_size;
|
size_t zip_path_size;
|
||||||
struct string_list *ext;
|
struct string_list *ext;
|
||||||
bool found_rom;
|
bool found_rom;
|
||||||
@ -323,8 +324,13 @@ static bool zip_extract_cb(const char *name, const uint8_t *cdata, unsigned cmod
|
|||||||
if (ext && string_list_find_elem(data->ext, ext))
|
if (ext && string_list_find_elem(data->ext, ext))
|
||||||
{
|
{
|
||||||
char new_path[PATH_MAX];
|
char new_path[PATH_MAX];
|
||||||
fill_pathname_resolve_relative(new_path, data->zip_path,
|
|
||||||
path_basename(name), sizeof(new_path));
|
if (data->extraction_directory)
|
||||||
|
fill_pathname_join(new_path, data->extraction_directory,
|
||||||
|
path_basename(name), sizeof(new_path));
|
||||||
|
else
|
||||||
|
fill_pathname_resolve_relative(new_path, data->zip_path,
|
||||||
|
path_basename(name), sizeof(new_path));
|
||||||
|
|
||||||
switch (cmode)
|
switch (cmode)
|
||||||
{
|
{
|
||||||
@ -350,7 +356,8 @@ static bool zip_extract_cb(const char *name, const uint8_t *cdata, unsigned cmod
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zlib_extract_first_rom(char *zip_path, size_t zip_path_size, const char *valid_exts)
|
bool zlib_extract_first_rom(char *zip_path, size_t zip_path_size, const char *valid_exts,
|
||||||
|
const char *extraction_directory)
|
||||||
{
|
{
|
||||||
bool ret;
|
bool ret;
|
||||||
struct zip_extract_userdata userdata = {0};
|
struct zip_extract_userdata userdata = {0};
|
||||||
@ -369,6 +376,7 @@ bool zlib_extract_first_rom(char *zip_path, size_t zip_path_size, const char *va
|
|||||||
|
|
||||||
userdata.zip_path = zip_path;
|
userdata.zip_path = zip_path;
|
||||||
userdata.zip_path_size = zip_path_size;
|
userdata.zip_path_size = zip_path_size;
|
||||||
|
userdata.extraction_directory = extraction_directory;
|
||||||
userdata.ext = list;
|
userdata.ext = list;
|
||||||
|
|
||||||
if (!zlib_parse_file(zip_path, zip_extract_cb, &userdata))
|
if (!zlib_parse_file(zip_path, zip_extract_cb, &userdata))
|
||||||
|
@ -30,7 +30,7 @@ typedef bool (*zlib_file_cb)(const char *name,
|
|||||||
bool zlib_parse_file(const char *file, zlib_file_cb file_cb, void *userdata);
|
bool zlib_parse_file(const char *file, zlib_file_cb file_cb, void *userdata);
|
||||||
|
|
||||||
// Built with zlib_parse_file.
|
// Built with zlib_parse_file.
|
||||||
bool zlib_extract_first_rom(char *zip_path, size_t zip_path_size, const char *valid_exts);
|
bool zlib_extract_first_rom(char *zip_path, size_t zip_path_size, const char *valid_exts, const char *extraction_dir);
|
||||||
struct string_list *zlib_get_file_list(const char *path);
|
struct string_list *zlib_get_file_list(const char *path);
|
||||||
|
|
||||||
bool zlib_inflate_data_to_file(const char *path, const uint8_t *data,
|
bool zlib_inflate_data_to_file(const char *path, const uint8_t *data,
|
||||||
|
@ -286,6 +286,8 @@ struct settings
|
|||||||
char screenshot_directory[PATH_MAX];
|
char screenshot_directory[PATH_MAX];
|
||||||
char system_directory[PATH_MAX];
|
char system_directory[PATH_MAX];
|
||||||
|
|
||||||
|
char extraction_directory[PATH_MAX];
|
||||||
|
|
||||||
bool rewind_enable;
|
bool rewind_enable;
|
||||||
size_t rewind_buffer_size;
|
size_t rewind_buffer_size;
|
||||||
unsigned rewind_granularity;
|
unsigned rewind_granularity;
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
# This will be overridden by explicit command line options.
|
# This will be overridden by explicit command line options.
|
||||||
# savestate_directory =
|
# savestate_directory =
|
||||||
|
|
||||||
|
# If set to a directory, ROMs which are temporarily extracted
|
||||||
|
# will be extracted to this directory.
|
||||||
|
# extraction_directory =
|
||||||
|
|
||||||
# Automatically saves a savestate at the end of RetroArch's lifetime.
|
# Automatically saves a savestate at the end of RetroArch's lifetime.
|
||||||
# The path is $SRAM_PATH.auto.
|
# The path is $SRAM_PATH.auto.
|
||||||
# RetroArch will automatically load any savestate with this path on startup if savestate_auto_load is set.
|
# RetroArch will automatically load any savestate with this path on startup if savestate_auto_load is set.
|
||||||
|
@ -376,6 +376,7 @@ void config_set_defaults(void)
|
|||||||
*g_settings.cheat_settings_path = '\0';
|
*g_settings.cheat_settings_path = '\0';
|
||||||
*g_settings.screenshot_directory = '\0';
|
*g_settings.screenshot_directory = '\0';
|
||||||
*g_settings.system_directory = '\0';
|
*g_settings.system_directory = '\0';
|
||||||
|
*g_settings.extraction_directory = '\0';
|
||||||
*g_settings.input.autoconfig_dir = '\0';
|
*g_settings.input.autoconfig_dir = '\0';
|
||||||
*g_settings.input.overlay = '\0';
|
*g_settings.input.overlay = '\0';
|
||||||
*g_settings.content_directory = '\0';
|
*g_settings.content_directory = '\0';
|
||||||
@ -929,6 +930,7 @@ bool config_load_file(const char *path, bool set_defaults)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CONFIG_GET_PATH(extraction_directory, "extraction_directory");
|
||||||
CONFIG_GET_PATH(content_directory, "content_directory");
|
CONFIG_GET_PATH(content_directory, "content_directory");
|
||||||
if (!strcmp(g_settings.content_directory, "default"))
|
if (!strcmp(g_settings.content_directory, "default"))
|
||||||
*g_settings.content_directory = '\0';
|
*g_settings.content_directory = '\0';
|
||||||
@ -1276,6 +1278,7 @@ bool config_save_file(const char *path)
|
|||||||
config_set_int(conf, "audio_out_rate", g_settings.audio.out_rate);
|
config_set_int(conf, "audio_out_rate", g_settings.audio.out_rate);
|
||||||
|
|
||||||
config_set_path(conf, "system_directory", *g_settings.system_directory ? g_settings.system_directory : "default");
|
config_set_path(conf, "system_directory", *g_settings.system_directory ? g_settings.system_directory : "default");
|
||||||
|
config_set_path(conf, "extraction_directory", g_settings.extraction_directory);
|
||||||
config_set_string(conf, "audio_resampler", g_settings.audio.resampler);
|
config_set_string(conf, "audio_resampler", g_settings.audio.resampler);
|
||||||
config_set_path(conf, "savefile_directory", *g_extern.savefile_dir ? g_extern.savefile_dir : "default");
|
config_set_path(conf, "savefile_directory", *g_extern.savefile_dir ? g_extern.savefile_dir : "default");
|
||||||
config_set_path(conf, "savestate_directory", *g_extern.savestate_dir ? g_extern.savestate_dir : "default");
|
config_set_path(conf, "savestate_directory", *g_extern.savestate_dir ? g_extern.savestate_dir : "default");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user