Update dirs.c

This commit is contained in:
twinaphex 2016-09-17 14:49:35 +02:00
parent 1a554cf1bc
commit 4d317ba5d7
5 changed files with 47 additions and 16 deletions

View File

@ -38,6 +38,7 @@
#include "input/input_remapping.h"
#include "defaults.h"
#include "core.h"
#include "dirs.h"
#include "paths.h"
#include "retroarch.h"
#include "runloop.h"
@ -1279,12 +1280,12 @@ static void config_set_defaults(void)
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH) &&
!string_is_empty(g_defaults.dir.savestate))
strlcpy(global->dir.savestate,
g_defaults.dir.savestate, sizeof(global->dir.savestate));
dir_set_savestate(g_defaults.dir.savestate);
if (!retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_SAVE_PATH) &&
!string_is_empty(g_defaults.dir.sram))
strlcpy(global->dir.savefile,
g_defaults.dir.sram, sizeof(global->dir.savefile));
dir_set_savefile(g_defaults.dir.sram);
if (!string_is_empty(g_defaults.dir.system))
strlcpy(settings->directory.system,
g_defaults.dir.system, sizeof(settings->directory.system));
@ -2060,12 +2061,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"))
strlcpy(global->dir.savefile, g_defaults.dir.sram,
sizeof(global->dir.savefile));
dir_set_savefile(g_defaults.dir.sram);
else if (path_is_directory(tmp_str))
{
strlcpy(global->dir.savefile, tmp_str,
sizeof(global->dir.savefile));
dir_set_savefile(tmp_str);
strlcpy(global->name.savefile, tmp_str,
sizeof(global->name.savefile));
fill_pathname_dir(global->name.savefile,
@ -2081,12 +2082,11 @@ 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"))
strlcpy(global->dir.savestate, g_defaults.dir.savestate,
sizeof(global->dir.savestate));
dir_set_savestate(g_defaults.dir.savestate);
else if (path_is_directory(tmp_str))
{
strlcpy(global->dir.savestate, tmp_str,
sizeof(global->dir.savestate));
dir_set_savestate(tmp_str);
strlcpy(global->name.savestate, tmp_str,
sizeof(global->name.savestate));
fill_pathname_dir(global->name.savestate,

24
dirs.c
View File

@ -26,3 +26,27 @@
#endif
#include "dirs.h"
#include "runloop.h"
void dir_set_savestate(const char *path)
{
global_t *global = global_get_ptr();
if (global)
strlcpy(global->dir.savestate, global->name.savefile,
sizeof(global->dir.savestate));
}
void dir_set_savefile(const char *path)
{
global_t *global = global_get_ptr();
if (global)
strlcpy(global->dir.savefile, global->name.savefile,
sizeof(global->dir.savefile));
}
void dir_clear_all(void)
{
}

6
dirs.h
View File

@ -21,6 +21,12 @@
RETRO_BEGIN_DECLS
void dir_set_savefile(const char *path);
void dir_set_savestate(const char *path);
void dir_clear_all(void);
RETRO_END_DECLS
#endif

View File

@ -64,6 +64,7 @@
#include "driver.h"
#include "msg_hash.h"
#include "movie.h"
#include "dirs.h"
#include "paths.h"
#include "file_path_special.h"
#include "verbosity.h"
@ -857,13 +858,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(global->name.savefile))
strlcpy(global->dir.savefile, global->name.savefile,
sizeof(global->dir.savefile));
dir_set_savefile(global->name.savefile);
if (retroarch_override_setting_is_set(RARCH_OVERRIDE_SETTING_STATE_PATH) &&
path_is_directory(global->name.savestate))
strlcpy(global->dir.savestate, global->name.savestate,
sizeof(global->dir.savestate));
dir_set_savestate(global->name.savestate);
}
static bool retroarch_init_state(void)

View File

@ -61,6 +61,7 @@
#include "configuration.h"
#include "driver.h"
#include "movie.h"
#include "dirs.h"
#include "paths.h"
#include "retroarch.h"
#include "runloop.h"
@ -916,6 +917,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
global = global_get_ptr();
path_clear_all();
dir_clear_all();
memset(global, 0, sizeof(struct global));
retroarch_override_setting_free_state();
config_free_state();