(RARCH_CONSOLE) Add new Unzip mode : Unzip, Load First File, Then Delete

- tested first on PS3
This commit is contained in:
twinaphex 2013-01-13 07:11:42 +01:00
parent 02478ca25f
commit 15cbab4876
5 changed files with 48 additions and 6 deletions

View File

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

View File

@ -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))
{

View File

@ -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 <<MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE))
{
snprintf(current_item->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 <<MODE_UNZIP_TO_CURDIR_AND_LOAD_FIRST_FILE_AND_CLEAN))
{
snprintf(current_item->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);
}

View File

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

View File

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