Skip to content

Commit

Permalink
Don't use global state anymore for dirs
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Sep 17, 2016
1 parent baf2862 commit edb3edf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 61 deletions.
77 changes: 18 additions & 59 deletions dirs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
2 changes: 0 additions & 2 deletions runloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit edb3edf

Please sign in to comment.