Create dir_set

This commit is contained in:
twinaphex 2016-09-30 07:15:30 +02:00
parent db3738babb
commit d973e528f6
5 changed files with 36 additions and 39 deletions

View File

@ -1285,7 +1285,7 @@ static void config_set_defaults(void)
sizeof(settings->path.osk_overlay));
#endif
dir_set_osk_overlay(temp_path);
dir_set(RARCH_DIR_OSK_OVERLAY, temp_path);
}
else
{
@ -1295,7 +1295,7 @@ static void config_set_defaults(void)
settings->directory.overlay,
sizeof(temp_path));
dir_set_osk_overlay(temp_path);
dir_set(RARCH_DIR_OSK_OVERLAY, temp_path);
}
#endif
#ifdef HAVE_MENU
@ -1315,11 +1315,11 @@ static void config_set_defaults(void)
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH) &&
!string_is_empty(g_defaults.dir.savestate))
dir_set_savestate(g_defaults.dir.savestate);
dir_set(RARCH_DIR_SAVESTATE, g_defaults.dir.savestate);
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH) &&
!string_is_empty(g_defaults.dir.sram))
dir_set_savefile(g_defaults.dir.sram);
dir_set(RARCH_DIR_SAVEFILE, g_defaults.dir.sram);
if (!string_is_empty(g_defaults.dir.system))
strlcpy(settings->directory.system,
@ -2109,12 +2109,12 @@ static bool config_load_file(const char *path, bool set_defaults,
config_get_path(conf, "savefile_directory", tmp_str, sizeof(tmp_str)))
{
if (string_is_equal(tmp_str, "default"))
dir_set_savefile(g_defaults.dir.sram);
dir_set(RARCH_DIR_SAVEFILE, g_defaults.dir.sram);
else if (path_is_directory(tmp_str))
{
char tmp_str_local[PATH_MAX_LENGTH] = {0};
dir_set_savefile(tmp_str);
dir_set(RARCH_DIR_SAVEFILE, tmp_str);
strlcpy(tmp_str_local, tmp_str,
sizeof(tmp_str_local));
@ -2133,12 +2133,13 @@ static bool config_load_file(const char *path, bool set_defaults,
config_get_path(conf, "savestate_directory", tmp_str, sizeof(tmp_str)))
{
if (string_is_equal(tmp_str, "default"))
dir_set_savestate(g_defaults.dir.savestate);
dir_set(RARCH_DIR_SAVESTATE, g_defaults.dir.savestate);
else if (path_is_directory(tmp_str))
{
char tmp_str_local[PATH_MAX_LENGTH] = {0};
dir_set_savestate(tmp_str);
dir_set(RARCH_DIR_SAVESTATE, tmp_str);
strlcpy(tmp_str_local, tmp_str,
sizeof(tmp_str_local));

44
dirs.c
View File

@ -288,28 +288,30 @@ const char *dir_get(enum rarch_dir_type type)
/* set functions */
void dir_set_osk_overlay(const char *path)
void dir_set(enum rarch_dir_type type, const char *path)
{
strlcpy(dir_osk_overlay, path,
sizeof(dir_osk_overlay));
}
void dir_set_system(const char *path)
{
strlcpy(dir_system, path,
sizeof(dir_system));
}
void dir_set_savestate(const char *path)
{
strlcpy(dir_savestate, path,
sizeof(dir_savestate));
}
void dir_set_savefile(const char *path)
{
strlcpy(dir_savefile, path,
sizeof(dir_savefile));
switch (type)
{
case RARCH_DIR_OSK_OVERLAY:
strlcpy(dir_osk_overlay, path,
sizeof(dir_osk_overlay));
break;
case RARCH_DIR_SYSTEM:
strlcpy(dir_system, path,
sizeof(dir_system));
break;
case RARCH_DIR_SAVESTATE:
strlcpy(dir_savestate, path,
sizeof(dir_savestate));
break;
case RARCH_DIR_SAVEFILE:
strlcpy(dir_savefile, path,
sizeof(dir_savefile));
break;
case RARCH_DIR_NONE:
default:
break;
}
}
static void check_defaults_dir_create_dir(const char *path)

8
dirs.h
View File

@ -80,13 +80,7 @@ const char *dir_get(enum rarch_dir_type type);
/* set functions */
void dir_set_osk_overlay(const char *path);
void dir_set_savefile(const char *path);
void dir_set_savestate(const char *path);
void dir_set_system(const char *path);
void dir_set(enum rarch_dir_type type, const char *path);
void dir_check_defaults(void);

View File

@ -1034,7 +1034,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n",
fullpath);
fill_pathname_basedir(temp_path, fullpath, sizeof(temp_path));
dir_set_system(temp_path);
dir_set(RARCH_DIR_SYSTEM, temp_path);
}
*(const char**)data = dir_get_system_ptr();

View File

@ -849,11 +849,11 @@ static void retroarch_parse_input(int argc, char *argv[])
/* Copy SRM/state dirs used, so they can be reused on reentrancy. */
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH) &&
path_is_directory(path_get(RARCH_PATH_SAVEFILE)))
dir_set_savefile(path_get(RARCH_PATH_SAVEFILE));
dir_set(RARCH_DIR_SAVEFILE, path_get(RARCH_PATH_SAVEFILE));
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH) &&
path_is_directory(path_get(RARCH_PATH_SAVESTATE)))
dir_set_savestate(path_get(RARCH_PATH_SAVESTATE));
dir_set(RARCH_DIR_SAVESTATE, path_get(RARCH_PATH_SAVESTATE));
}
static bool retroarch_init_state(void)