Don't use global state anymore for dirs

This commit is contained in:
twinaphex 2016-09-17 15:29:38 +02:00
parent baf2862b85
commit edb3edfef1
2 changed files with 18 additions and 61 deletions

77
dirs.c
View File

@ -27,114 +27,73 @@
#include "dirs.h"
#include "runloop.h"
static char dir_savefile[PATH_MAX_LENGTH] = {0};
static char dir_savestate[PATH_MAX_LENGTH] = {0};
bool dir_is_savefile_empty(void)
{
global_t *global = global_get_ptr();
if (!global)
return false;
return string_is_empty(global->dir.savefile);
return string_is_empty(dir_savefile);
}
bool dir_is_savestate_empty(void)
{
global_t *global = global_get_ptr();
if (!global)
return false;
return string_is_empty(global->dir.savestate);
return string_is_empty(dir_savestate);
}
size_t dir_get_savestate_size(void)
{
global_t *global = global_get_ptr();
if (!global)
return 0;
return sizeof(global->dir.savestate);
return sizeof(dir_savestate);
}
size_t dir_get_savefile_size(void)
{
global_t *global = global_get_ptr();
if (!global)
return 0;
return sizeof(global->dir.savefile);
return sizeof(dir_savefile);
}
void dir_clear_savefile(void)
{
global_t *global = global_get_ptr();
if (global)
*global->dir.savefile = '\0';
*dir_savefile = '\0';
}
void dir_clear_savestate(void)
{
global_t *global = global_get_ptr();
if (global)
*global->dir.savestate = '\0';
*dir_savestate = '\0';
}
char *dir_get_savefile_ptr(void)
{
global_t *global = global_get_ptr();
if (!global)
return NULL;
return global->dir.savefile;
return dir_savefile;
}
const char *dir_get_savefile(void)
{
global_t *global = global_get_ptr();
if (!global)
return NULL;
return global->dir.savefile;
return dir_savefile;
}
char *dir_get_savestate_ptr(void)
{
global_t *global = global_get_ptr();
if (!global)
return NULL;
return global->dir.savestate;
return dir_savestate;
}
const char *dir_get_savestate(void)
{
global_t *global = global_get_ptr();
if (!global)
return NULL;
return global->dir.savestate;
return dir_savestate;
}
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));
strlcpy(dir_savestate, path,
sizeof(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));
strlcpy(dir_savefile, path,
sizeof(dir_savefile));
}
void dir_clear_all(void)
{
dir_clear_savefile();
dir_clear_savestate();
}

View File

@ -143,8 +143,6 @@ enum runloop_ctl_state
typedef struct rarch_dir
{
/* Used on reentrancy to use a savestate dir. */
char savefile[PATH_MAX_LENGTH];
char savestate[PATH_MAX_LENGTH];
char systemdir[PATH_MAX_LENGTH];
#ifdef HAVE_OVERLAY
char osk_overlay[PATH_MAX_LENGTH];