make system directory restore correctly when closing content in case it was set to content dir

This commit is contained in:
radius 2015-07-12 02:28:59 -05:00
parent d9b125a645
commit 06f656004b
4 changed files with 14 additions and 6 deletions

View File

@ -547,6 +547,9 @@ static void event_deinit_core(bool reinit)
if(settings->sort_savestates_enable) if(settings->sort_savestates_enable)
strlcpy(global->savestate_dir,orig_savestate_dir,sizeof(global->savestate_dir)); strlcpy(global->savestate_dir,orig_savestate_dir,sizeof(global->savestate_dir));
if(orig_system_dir_empty)
strlcpy(settings->system_directory,"",sizeof(settings->system_directory));
/* auto overrides: reload the original config */ /* auto overrides: reload the original config */
if(global->overrides_active) if(global->overrides_active)
{ {

View File

@ -43,9 +43,9 @@ void main_exit_save_config(void)
{ {
/* restore original paths in case per-core organization is enabled */ /* restore original paths in case per-core organization is enabled */
if (settings->sort_savefiles_enable && orig_savefile_dir[0] != '\0') if (settings->sort_savefiles_enable && orig_savefile_dir[0] != '\0')
strlcpy(global->savefile_dir,orig_savefile_dir,sizeof(global->savefile_dir)); strlcpy(global->savefile_dir,orig_savefile_dir,sizeof(global->savefile_dir));
if (settings->sort_savestates_enable && orig_savestate_dir[0] != '\0') if (settings->sort_savestates_enable && orig_savestate_dir[0] != '\0')
strlcpy(global->savestate_dir,orig_savestate_dir,sizeof(global->savestate_dir)); strlcpy(global->savestate_dir,orig_savestate_dir,sizeof(global->savestate_dir));
/* Save last core-specific config to the default config location, /* Save last core-specific config to the default config location,
* needed on consoles for core switching and reusing last good * needed on consoles for core switching and reusing last good

View File

@ -61,6 +61,7 @@
char orig_savestate_dir[PATH_MAX_LENGTH]; char orig_savestate_dir[PATH_MAX_LENGTH];
char orig_savefile_dir[PATH_MAX_LENGTH]; char orig_savefile_dir[PATH_MAX_LENGTH];
bool orig_system_dir_empty = false;
/* Descriptive names for options without short variant. Please keep the name in /* Descriptive names for options without short variant. Please keep the name in
sync with the option name. Order does not matter. */ sync with the option name. Order does not matter. */
@ -313,6 +314,8 @@ static void set_special_paths(char **argv, unsigned num_content)
/* If this is already set, /* If this is already set,
* do not overwrite it as this was initialized before in * do not overwrite it as this was initialized before in
* a menu or otherwise. */ * a menu or otherwise. */
if (settings->system_directory[0] == '\0')
orig_system_dir_empty = true;
if (!*settings->system_directory) if (!*settings->system_directory)
fill_pathname_basedir(settings->system_directory, argv[0], fill_pathname_basedir(settings->system_directory, argv[0],
sizeof(settings->system_directory)); sizeof(settings->system_directory));
@ -333,7 +336,7 @@ void set_paths_redirect(const char *path)
(global_library_name_hash != MENU_VALUE_NO_CORE)) (global_library_name_hash != MENU_VALUE_NO_CORE))
{ {
/* per-core saves: append the library_name to the save location */ /* per-core saves: append the library_name to the save location */
if (settings->sort_savefiles_enable) if (settings->sort_savefiles_enable && global->savefile_dir[0] != '\0')
{ {
strlcpy(orig_savefile_dir,global->savefile_dir,sizeof(global->savefile_dir)); strlcpy(orig_savefile_dir,global->savefile_dir,sizeof(global->savefile_dir));
fill_pathname_dir( fill_pathname_dir(
@ -344,7 +347,7 @@ void set_paths_redirect(const char *path)
/* If path doesn't exist, try to create it, /* If path doesn't exist, try to create it,
* if everything fails revert to the original path. */ * if everything fails revert to the original path. */
if(!path_is_directory(global->savefile_dir)) if(!path_is_directory(global->savefile_dir) && global->savestate_dir[0] != '\0')
if(!path_mkdir(global->savefile_dir)) if(!path_mkdir(global->savefile_dir))
strlcpy(global->savefile_dir, strlcpy(global->savefile_dir,
orig_savefile_dir, orig_savefile_dir,
@ -428,7 +431,8 @@ void rarch_set_paths(const char *path)
* as this was initialized before in a menu or otherwise. */ * as this was initialized before in a menu or otherwise. */
if (*settings->system_directory) if (*settings->system_directory)
return; return;
if (settings->system_directory[0] == '\0')
orig_system_dir_empty = true;
fill_pathname_basedir(settings->system_directory, path, fill_pathname_basedir(settings->system_directory, path,
sizeof(settings->system_directory)); sizeof(settings->system_directory));
} }

View File

@ -214,6 +214,7 @@ enum rarch_content_type rarch_path_is_media_type(const char *path);
extern char orig_savestate_dir[PATH_MAX_LENGTH]; extern char orig_savestate_dir[PATH_MAX_LENGTH];
extern char orig_savefile_dir[PATH_MAX_LENGTH]; extern char orig_savefile_dir[PATH_MAX_LENGTH];
extern bool orig_system_dir_empty;
#ifdef __cplusplus #ifdef __cplusplus
} }