Allow saving "empty" directories in config file

"default" gets translated to either ROM directory or platform-default directory, depending on the setting
This commit is contained in:
ToadKing 2013-05-20 22:18:34 -04:00
parent 655546849a
commit 1ef1960ad1

View File

@ -624,6 +624,8 @@ bool config_load_file(const char *path)
#ifdef HAVE_RGUI
CONFIG_GET_PATH(rgui_browser_directory, "rgui_browser_directory");
if (!strcmp(g_settings.rgui_browser_directory, "default"))
g_settings.rgui_browser_directory[0] = '\0';
#endif
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
@ -673,7 +675,11 @@ bool config_load_file(const char *path)
if (!g_extern.has_set_save_path && config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str)))
{
if (path_is_directory(tmp_str))
if (!strcmp(tmp_str, "default"))
{
g_extern.savefile_dir[0] = '\0';
}
else if (path_is_directory(tmp_str))
{
strlcpy(g_extern.savefile_dir, tmp_str, sizeof(g_extern.savefile_dir));
strlcpy(g_extern.savefile_name_srm, tmp_str, sizeof(g_extern.savefile_name_srm));
@ -685,7 +691,11 @@ bool config_load_file(const char *path)
if (!g_extern.has_set_state_path && config_get_path(conf, "savestate_directory", tmp_str, sizeof(tmp_str)))
{
if (path_is_directory(tmp_str))
if (!strcmp(tmp_str, "default"))
{
g_extern.savestate_dir[0] = '\0';
}
else if (path_is_directory(tmp_str))
{
strlcpy(g_extern.savestate_dir, tmp_str, sizeof(g_extern.savestate_dir));
strlcpy(g_extern.savestate_name, tmp_str, sizeof(g_extern.savestate_name));
@ -701,6 +711,11 @@ bool config_load_file(const char *path)
g_settings.system_directory);
}
if (!strcmp(g_settings.system_directory, "default"))
{
g_settings.system_directory[0] = '\0';
}
config_read_keybinds_conf(conf);
config_file_free(conf);
@ -920,10 +935,27 @@ bool config_save_file(const char *path)
config_set_string(conf, "audio_device", g_settings.audio.device);
config_set_bool(conf, "audio_rate_control", g_settings.audio.rate_control);
config_set_float(conf, "audio_rate_control_delta", g_settings.audio.rate_control_delta);
config_set_string(conf, "system_directory", g_settings.system_directory);
if (g_settings.system_directory[0] == '\0')
config_set_string(conf, "system_directory", "default");
else
config_set_string(conf, "system_directory", g_settings.system_directory);
if (g_extern.savefile_dir[0] == '\0')
config_set_string(conf, "savefile_directory", "default");
else
config_set_string(conf, "savefile_directory", g_extern.savefile_dir);
if (g_extern.savestate_dir[0] == '\0')
config_set_string(conf, "savestate_directory", "default");
else
config_set_string(conf, "savestate_directory", g_extern.savestate_dir);
#if defined(HAVE_RGUI) || defined(HAVE_RMENU)
config_set_string(conf, "rgui_browser_directory", g_settings.rgui_browser_directory);
if (g_settings.rgui_browser_directory[0] == '\0')
config_set_string(conf, "rgui_browser_directory", "default");
else
config_set_string(conf, "rgui_browser_directory", g_settings.rgui_browser_directory);
#endif
#ifdef ANDROID