@@ -1976,14 +1976,14 @@ bool runloop_environment_cb(unsigned cmd, void *data)
19761976
19771977 if (string_is_empty (dir_system ))
19781978 RARCH_WARN ("[Environ]: SYSTEM DIR is empty, assume CONTENT DIR %s\n" ,
1979- fullpath );
1979+ fullpath );
19801980
19811981 strlcpy (tmp_path , fullpath , sizeof (tmp_path ));
19821982 path_basedir (tmp_path );
19831983
19841984 /* Removes trailing slash (unless root dir) */
19851985 len = strlen (tmp_path );
1986- if ( string_count_occurrences_single_character (tmp_path , PATH_DEFAULT_SLASH_C ()) > 1
1986+ if (string_count_occurrences_single_character (tmp_path , PATH_DEFAULT_SLASH_C ()) > 1
19871987 && tmp_path [len - 1 ] == PATH_DEFAULT_SLASH_C ())
19881988 tmp_path [len - 1 ] = '\0' ;
19891989
@@ -2000,7 +2000,7 @@ bool runloop_environment_cb(unsigned cmd, void *data)
20002000 {
20012001 * (const char * * )data = dir_system ;
20022002 RARCH_LOG ("[Environ]: SYSTEM_DIRECTORY: \"%s\".\n" ,
2003- dir_system );
2003+ dir_system );
20042004 }
20052005 }
20062006 break ;
@@ -7925,144 +7925,144 @@ void runloop_path_set_names(void)
79257925}
79267926
79277927void runloop_path_set_redirect (settings_t * settings ,
7928- const char * old_savefile_dir ,
7929- const char * old_savestate_dir )
7928+ const char * old_savefile_dir ,
7929+ const char * old_savestate_dir )
79307930{
79317931 char content_dir_name [PATH_MAX_LENGTH ];
79327932 char new_savefile_dir [PATH_MAX_LENGTH ];
79337933 char new_savestate_dir [PATH_MAX_LENGTH ];
7934- runloop_state_t * runloop_st = & runloop_state ;
7935- struct retro_system_info * sysinfo = & runloop_st -> system .info ;
7936- bool sort_savefiles_enable = settings -> bools .sort_savefiles_enable ;
7937- bool sort_savefiles_by_content_enable = settings -> bools .sort_savefiles_by_content_enable ;
7938- bool sort_savestates_enable = settings -> bools .sort_savestates_enable ;
7939- bool sort_savestates_by_content_enable = settings -> bools .sort_savestates_by_content_enable ;
7940- bool savefiles_in_content_dir = settings -> bools .savefiles_in_content_dir ;
7941- bool savestates_in_content_dir = settings -> bools .savestates_in_content_dir ;
7934+ char intermediate_savefile_dir [PATH_MAX_LENGTH ];
7935+ char intermediate_savestate_dir [PATH_MAX_LENGTH ];
7936+ runloop_state_t * runloop_st = & runloop_state ;
7937+ struct retro_system_info * sysinfo = & runloop_st -> system .info ;
7938+ bool sort_savefiles_enable = settings -> bools .sort_savefiles_enable ;
7939+ bool sort_savefiles_by_content_enable = settings -> bools .sort_savefiles_by_content_enable ;
7940+ bool sort_savestates_enable = settings -> bools .sort_savestates_enable ;
7941+ bool sort_savestates_by_content_enable = settings -> bools .sort_savestates_by_content_enable ;
7942+ bool savefiles_in_content_dir = settings -> bools .savefiles_in_content_dir ;
7943+ bool savestates_in_content_dir = settings -> bools .savestates_in_content_dir ;
79427944
7943- content_dir_name [0 ] = '\0' ;
7945+ content_dir_name [0 ] = '\0' ;
79447946
79457947 /* Initialize current save directories
79467948 * with the values from the config. */
7947- strlcpy (new_savefile_dir , old_savefile_dir , sizeof (new_savefile_dir ));
7948- strlcpy (new_savestate_dir , old_savestate_dir , sizeof (new_savestate_dir ));
7949+ strlcpy (intermediate_savefile_dir , old_savefile_dir , sizeof (intermediate_savefile_dir ));
7950+ strlcpy (intermediate_savestate_dir , old_savestate_dir , sizeof (intermediate_savestate_dir ));
79497951
79507952 /* Get content directory name, if per-content-directory
79517953 * saves/states are enabled */
7952- if ( (sort_savefiles_by_content_enable
7953- || sort_savestates_by_content_enable )
7954- && !string_is_empty (runloop_st -> runtime_content_path_basename ))
7954+ if ((sort_savefiles_by_content_enable
7955+ || sort_savestates_by_content_enable )
7956+ && !string_is_empty (runloop_st -> runtime_content_path_basename ))
79557957 fill_pathname_parent_dir_name (content_dir_name ,
7956- runloop_st -> runtime_content_path_basename ,
7957- sizeof (content_dir_name ));
7958+ runloop_st -> runtime_content_path_basename ,
7959+ sizeof (content_dir_name ));
7960+
7961+ /* Set savefile directory if empty to content directory */
7962+ if (string_is_empty (intermediate_savefile_dir ) || savefiles_in_content_dir )
7963+ {
7964+ strlcpy (intermediate_savefile_dir ,
7965+ runloop_st -> runtime_content_path_basename ,
7966+ sizeof (intermediate_savefile_dir ));
7967+ path_basedir (intermediate_savefile_dir );
7968+
7969+ if (string_is_empty (intermediate_savefile_dir ))
7970+ RARCH_LOG ("Cannot resolve save file path.\n" );
7971+ }
7972+
7973+ /* Set savestate directory if empty based on content directory */
7974+ if (string_is_empty (intermediate_savestate_dir )
7975+ || savestates_in_content_dir )
7976+ {
7977+ strlcpy (intermediate_savestate_dir ,
7978+ runloop_st -> runtime_content_path_basename ,
7979+ sizeof (intermediate_savestate_dir ));
7980+ path_basedir (intermediate_savestate_dir );
7981+
7982+ if (string_is_empty (intermediate_savestate_dir ))
7983+ RARCH_LOG ("Cannot resolve save state file path.\n" );
7984+ }
7985+
7986+ strlcpy (new_savefile_dir , intermediate_savefile_dir , sizeof (new_savefile_dir ));
7987+ strlcpy (new_savestate_dir , intermediate_savestate_dir , sizeof (new_savestate_dir ));
79587988
79597989 if (sysinfo && !string_is_empty (sysinfo -> library_name ))
79607990 {
79617991#ifdef HAVE_MENU
79627992 if (!string_is_equal (sysinfo -> library_name ,
7963- msg_hash_to_str (MENU_ENUM_LABEL_VALUE_NO_CORE )))
7993+ msg_hash_to_str (MENU_ENUM_LABEL_VALUE_NO_CORE )))
79647994#endif
79657995 {
79667996 /* Per-core and/or per-content-directory saves */
7967- if (( sort_savefiles_enable
7968- || sort_savefiles_by_content_enable )
7969- && !string_is_empty (old_savefile_dir ))
7997+ if ((sort_savefiles_enable
7998+ || sort_savefiles_by_content_enable )
7999+ && !string_is_empty (new_savefile_dir ))
79708000 {
79718001 /* Append content directory name to save location */
79728002 if (sort_savefiles_by_content_enable )
79738003 fill_pathname_join_special (
7974- new_savefile_dir ,
7975- old_savefile_dir ,
7976- content_dir_name ,
7977- sizeof (new_savefile_dir ));
8004+ new_savefile_dir ,
8005+ new_savefile_dir ,
8006+ content_dir_name ,
8007+ sizeof (new_savefile_dir ));
79788008
79798009 /* Append library_name to the save location */
79808010 if (sort_savefiles_enable )
79818011 fill_pathname_join (
7982- new_savefile_dir ,
7983- new_savefile_dir ,
7984- sysinfo -> library_name ,
7985- sizeof (new_savefile_dir ));
8012+ new_savefile_dir ,
8013+ new_savefile_dir ,
8014+ sysinfo -> library_name ,
8015+ sizeof (new_savefile_dir ));
79868016
79878017 /* If path doesn't exist, try to create it,
79888018 * if everything fails revert to the original path. */
79898019 if (!path_is_directory (new_savefile_dir ))
79908020 if (!path_mkdir (new_savefile_dir ))
79918021 {
79928022 RARCH_LOG ("%s %s\n" ,
7993- msg_hash_to_str (MSG_REVERTING_SAVEFILE_DIRECTORY_TO ),
7994- old_savefile_dir );
8023+ msg_hash_to_str (MSG_REVERTING_SAVEFILE_DIRECTORY_TO ),
8024+ intermediate_savefile_dir );
79958025
7996- strlcpy (new_savefile_dir , old_savefile_dir , sizeof (new_savefile_dir ));
8026+ strlcpy (new_savefile_dir , intermediate_savefile_dir , sizeof (new_savefile_dir ));
79978027 }
79988028 }
79998029
80008030 /* Per-core and/or per-content-directory savestates */
80018031 if ((sort_savestates_enable || sort_savestates_by_content_enable )
8002- && !string_is_empty (old_savestate_dir ))
8032+ && !string_is_empty (new_savestate_dir ))
80038033 {
80048034 /* Append content directory name to savestate location */
80058035 if (sort_savestates_by_content_enable )
80068036 fill_pathname_join_special (
8007- new_savestate_dir ,
8008- old_savestate_dir ,
8009- content_dir_name ,
8010- sizeof (new_savestate_dir ));
8037+ new_savestate_dir ,
8038+ new_savestate_dir ,
8039+ content_dir_name ,
8040+ sizeof (new_savestate_dir ));
80118041
80128042 /* Append library_name to the savestate location */
80138043 if (sort_savestates_enable )
80148044 fill_pathname_join (
8015- new_savestate_dir ,
8016- new_savestate_dir ,
8017- sysinfo -> library_name ,
8018- sizeof (new_savestate_dir ));
8045+ new_savestate_dir ,
8046+ new_savestate_dir ,
8047+ sysinfo -> library_name ,
8048+ sizeof (new_savestate_dir ));
80198049
80208050 /* If path doesn't exist, try to create it.
80218051 * If everything fails, revert to the original path. */
80228052 if (!path_is_directory (new_savestate_dir ))
80238053 if (!path_mkdir (new_savestate_dir ))
80248054 {
80258055 RARCH_LOG ("%s %s\n" ,
8026- msg_hash_to_str (MSG_REVERTING_SAVESTATE_DIRECTORY_TO ),
8027- old_savestate_dir );
8056+ msg_hash_to_str (MSG_REVERTING_SAVESTATE_DIRECTORY_TO ),
8057+ intermediate_savestate_dir );
80288058 strlcpy (new_savestate_dir ,
8029- old_savestate_dir ,
8030- sizeof (new_savestate_dir ));
8059+ intermediate_savestate_dir ,
8060+ sizeof (new_savestate_dir ));
80318061 }
80328062 }
80338063 }
80348064 }
80358065
8036- /* Set savefile directory if empty to content directory */
8037- if (string_is_empty (new_savefile_dir ) || savefiles_in_content_dir )
8038- {
8039- strlcpy (new_savefile_dir ,
8040- runloop_st -> runtime_content_path_basename ,
8041- sizeof (new_savefile_dir ));
8042- path_basedir (new_savefile_dir );
8043-
8044- if (string_is_empty (new_savefile_dir ))
8045- RARCH_LOG ("Cannot resolve save file path.\n" );
8046- else if (sort_savefiles_enable
8047- || sort_savefiles_by_content_enable )
8048- RARCH_LOG ("Saving files in content directory is set. This overrides other save file directory settings.\n" );
8049- }
8050-
8051- /* Set savestate directory if empty based on content directory */
8052- if ( string_is_empty (new_savestate_dir )
8053- || savestates_in_content_dir )
8054- {
8055- strlcpy (new_savestate_dir ,
8056- runloop_st -> runtime_content_path_basename ,
8057- sizeof (new_savestate_dir ));
8058- path_basedir (new_savestate_dir );
8059-
8060- if (string_is_empty (new_savestate_dir ))
8061- RARCH_LOG ("Cannot resolve save state file path.\n" );
8062- else if (sort_savestates_enable
8063- || sort_savestates_by_content_enable )
8064- RARCH_LOG ("Saving save states in content directory is set. This overrides other save state file directory settings.\n" );
8065- }
80668066
80678067#ifdef HAVE_NETWORKING
80688068 /* Special save directory for netplay clients. */
@@ -8085,50 +8085,49 @@ void runloop_path_set_redirect(settings_t *settings,
80858085 bool savestate_is_dir = path_is_directory (new_savestate_dir );
80868086 if (savefile_is_dir )
80878087 strlcpy (runloop_st -> name .savefile , new_savefile_dir ,
8088- sizeof (runloop_st -> name .savefile ));
8088+ sizeof (runloop_st -> name .savefile ));
80898089 else
8090- savefile_is_dir = path_is_directory (runloop_st -> name .savefile );
8090+ savefile_is_dir = path_is_directory (runloop_st -> name .savefile );
80918091
80928092 if (savestate_is_dir )
80938093 {
80948094 strlcpy (runloop_st -> name .savestate , new_savestate_dir ,
80958095 sizeof (runloop_st -> name .savestate ));
80968096 strlcpy (runloop_st -> name .replay , new_savestate_dir ,
80978097 sizeof (runloop_st -> name .replay ));
8098- }
8099- else
8100- savestate_is_dir = path_is_directory (runloop_st -> name .savestate );
8098+ } else
8099+ savestate_is_dir = path_is_directory (runloop_st -> name .savestate );
81018100
81028101 if (savefile_is_dir )
81038102 {
81048103 fill_pathname_dir (runloop_st -> name .savefile ,
8105- !string_is_empty (runloop_st -> runtime_content_path_basename )
8106- ? runloop_st -> runtime_content_path_basename
8107- : sysinfo -> library_name ,
8108- FILE_PATH_SRM_EXTENSION ,
8109- sizeof (runloop_st -> name .savefile ));
8104+ !string_is_empty (runloop_st -> runtime_content_path_basename )
8105+ ? runloop_st -> runtime_content_path_basename
8106+ : sysinfo -> library_name ,
8107+ FILE_PATH_SRM_EXTENSION ,
8108+ sizeof (runloop_st -> name .savefile ));
81108109 RARCH_LOG ("[Overrides]: %s \"%s\".\n" ,
8111- msg_hash_to_str (MSG_REDIRECTING_SAVEFILE_TO ),
8112- runloop_st -> name .savefile );
8110+ msg_hash_to_str (MSG_REDIRECTING_SAVEFILE_TO ),
8111+ runloop_st -> name .savefile );
81138112 }
81148113
81158114 if (savestate_is_dir )
81168115 {
81178116 fill_pathname_dir (runloop_st -> name .savestate ,
8118- !string_is_empty (runloop_st -> runtime_content_path_basename )
8119- ? runloop_st -> runtime_content_path_basename
8120- : sysinfo -> library_name ,
8121- FILE_PATH_STATE_EXTENSION ,
8122- sizeof (runloop_st -> name .savestate ));
8117+ !string_is_empty (runloop_st -> runtime_content_path_basename )
8118+ ? runloop_st -> runtime_content_path_basename
8119+ : sysinfo -> library_name ,
8120+ FILE_PATH_STATE_EXTENSION ,
8121+ sizeof (runloop_st -> name .savestate ));
81238122 fill_pathname_dir (runloop_st -> name .replay ,
8124- !string_is_empty (runloop_st -> runtime_content_path_basename )
8125- ? runloop_st -> runtime_content_path_basename
8126- : sysinfo -> library_name ,
8127- FILE_PATH_BSV_EXTENSION ,
8128- sizeof (runloop_st -> name .replay ));
8123+ !string_is_empty (runloop_st -> runtime_content_path_basename )
8124+ ? runloop_st -> runtime_content_path_basename
8125+ : sysinfo -> library_name ,
8126+ FILE_PATH_BSV_EXTENSION ,
8127+ sizeof (runloop_st -> name .replay ));
81298128 RARCH_LOG ("[Overrides]: %s \"%s\".\n" ,
8130- msg_hash_to_str (MSG_REDIRECTING_SAVESTATE_TO ),
8131- runloop_st -> name .savestate );
8129+ msg_hash_to_str (MSG_REDIRECTING_SAVESTATE_TO ),
8130+ runloop_st -> name .savestate );
81328131 }
81338132
81348133#ifdef HAVE_CHEATS
@@ -8147,7 +8146,7 @@ void runloop_path_set_redirect(settings_t *settings,
81478146#endif
81488147 }
81498148
8150- dir_set (RARCH_DIR_CURRENT_SAVEFILE , new_savefile_dir );
8149+ dir_set (RARCH_DIR_CURRENT_SAVEFILE , new_savefile_dir );
81518150 dir_set (RARCH_DIR_CURRENT_SAVESTATE , new_savestate_dir );
81528151}
81538152
0 commit comments