Skip to content

Commit

Permalink
Create dir_set
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 30, 2016
1 parent db3738b commit d973e52
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 39 deletions.
17 changes: 9 additions & 8 deletions configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down
44 changes: 23 additions & 21 deletions dirs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 1 addition & 7 deletions dirs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions retroarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d973e52

Please sign in to comment.