diff --git a/console/rarch_zlib.c b/console/rarch_zlib.c index 35d73689be..d3805ab925 100644 --- a/console/rarch_zlib.c +++ b/console/rarch_zlib.c @@ -69,7 +69,9 @@ static int rarch_zlib_extract_file(unzFile uf, } if ((g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR)) || - (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE))) + (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE)) || + (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN)) + ) fill_pathname_join(out_fname, current_dir, fname_inzip, out_fname_size); #if defined(HAVE_HDD_CACHE_PARTITION) && defined(RARCH_CONSOLE) else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CACHEDIR)) diff --git a/frontend/frontend_console.c b/frontend/frontend_console.c index 48f0ec5c78..6a817fbd98 100644 --- a/frontend/frontend_console.c +++ b/frontend/frontend_console.c @@ -115,12 +115,17 @@ void console_load_game(const char *path) if(g_extern.lifecycle_mode_state & (1ULL << MODE_INFO_DRAW)) rmenu_settings_msg(S_MSG_EXTRACTED_ZIPFILE, S_DELAY_180); - if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE)) + if ((g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE)) || + (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN))) { if (first_file[0] != 0) { RARCH_LOG("Found compatible game, loading it...\n"); snprintf(g_extern.fullpath, sizeof(g_extern.fullpath), first_file); + + if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN)) + g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_DELETE_PENDING); + goto do_init; } else @@ -345,6 +350,16 @@ begin_loop: rmenu_settings_msg(S_MSG_ROM_LOADING_ERROR, S_DELAY_180); } g_extern.lifecycle_mode_state &= ~(1ULL << MODE_INIT); +#ifdef HAVE_ZLIB + if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_DELETE_PENDING)) + { + int ret = remove(g_extern.fullpath); + + if (ret == 0) + RARCH_LOG("Removed temporary unzipped ROM file: [%s].\n", g_extern.fullpath); + g_extern.lifecycle_mode_state &= ~(1ULL << MODE_UNZIP_DELETE_PENDING); + } +#endif } else if(g_extern.lifecycle_mode_state & (1ULL << MODE_MENU)) { diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index f3d91bf689..8c2579b096 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -309,7 +309,7 @@ static void populate_setting_item(void *data, unsigned input) break; #ifdef HAVE_ZLIB case SETTING_ZIP_EXTRACT: - snprintf(current_item->text, sizeof(current_item->text), "ZIP Extract Option"); + snprintf(current_item->text, sizeof(current_item->text), "Unzip mode"); if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR)) { snprintf(current_item->setting_text, sizeof(current_item->setting_text), "Current dir"); @@ -317,9 +317,14 @@ static void populate_setting_item(void *data, unsigned input) } else if (g_extern.lifecycle_mode_state & (1ULL <setting_text, sizeof(current_item->setting_text), "Current dir and load first file"); + snprintf(current_item->setting_text, sizeof(current_item->setting_text), "Current dir, load first file"); snprintf(current_item->comment, sizeof(current_item->comment), "INFO - ZIP files are extracted to current dir, and auto-loaded."); } + else if (g_extern.lifecycle_mode_state & (1ULL <setting_text, sizeof(current_item->setting_text), "Current dir, load first file and cleanup"); + snprintf(current_item->comment, sizeof(current_item->comment), "INFO - ZIP files are extracted to current dir, auto-loaded and then\n removed afterwards."); + } else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CACHEDIR)) { snprintf(current_item->setting_text, sizeof(current_item->setting_text), "Cache dir"); @@ -1433,13 +1438,19 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input) if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CACHEDIR)) { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_UNZIP_TO_CACHEDIR); - g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE); + g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN); } else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE)) { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE); g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CURDIR); } + + else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN)) + { + g_extern.lifecycle_mode_state &= ~(1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN); + g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE); + } } if((input & (1ULL << RMENU_DEVICE_NAV_RIGHT)) || (input & (1ULL << RMENU_DEVICE_NAV_B))) { @@ -1451,6 +1462,11 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input) else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE)) { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE); + g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN); + } + else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN)) + { + g_extern.lifecycle_mode_state &= ~(1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN); g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CACHEDIR); } } @@ -1458,6 +1474,7 @@ static int set_setting_action(void *data, unsigned switchvalue, uint64_t input) { g_extern.lifecycle_mode_state &= ~((1ULL << MODE_UNZIP_TO_CURDIR) | (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE) | + (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN) | (1ULL << MODE_UNZIP_TO_CACHEDIR)); g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE); } diff --git a/general.h b/general.h index 637e864e38..aa7f794ac2 100644 --- a/general.h +++ b/general.h @@ -132,7 +132,9 @@ enum menu_enums MODE_AUDIO_CUSTOM_BGM_ENABLE, MODE_UNZIP_TO_CURDIR, MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE, + MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN, MODE_UNZIP_TO_CACHEDIR, + MODE_UNZIP_DELETE_PENDING, }; // All config related settings go here. diff --git a/settings.c b/settings.c index 0e85d9e82a..c2d82c8600 100644 --- a/settings.c +++ b/settings.c @@ -553,6 +553,7 @@ bool config_load_file(const char *path) { g_extern.lifecycle_mode_state &= ~((1ULL << MODE_UNZIP_TO_CURDIR) | (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE) | + (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN) | (1ULL << MODE_UNZIP_TO_CACHEDIR)); switch(zip_extract_mode) { @@ -563,6 +564,9 @@ bool config_load_file(const char *path) g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE); break; case 2: + g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN); + break; + case 3: g_extern.lifecycle_mode_state |= (1ULL << MODE_UNZIP_TO_CACHEDIR); break; } @@ -1226,8 +1230,10 @@ bool config_save_file(const char *path) config_set_int(conf, "unzip_mode", 0); else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE)) config_set_int(conf, "unzip_mode", 1); - else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CACHEDIR)) + else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN)) config_set_int(conf, "unzip_mode", 2); + else if (g_extern.lifecycle_mode_state & (1ULL << MODE_UNZIP_TO_CACHEDIR)) + config_set_int(conf, "unzip_mode", 3); config_set_int(conf, "flicker_filter_index", g_extern.console.screen.flicker_filter_index); config_set_int(conf, "soft_filter_index", g_extern.console.screen.soft_filter_index);