Replace direct file access with VFS routines
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <file/file_path.h>
|
||||
|
||||
#include "fceu-types.h"
|
||||
#include "fceu.h"
|
||||
|
||||
@@ -41,25 +43,14 @@
|
||||
|
||||
#include "md5.h"
|
||||
|
||||
static char BaseDirectory[2048];
|
||||
static char SaveDirectory[2048];
|
||||
static char FileBase[2048];
|
||||
static char FileExt[2048]; /* Includes the . character, as in ".nes" */
|
||||
static char BaseDirectory[2048] = {0};
|
||||
|
||||
static char FileBaseDirectory[2048];
|
||||
|
||||
void FCEUI_SetBaseDirectory(char *dir)
|
||||
void FCEUI_SetBaseDirectory(const char *dir)
|
||||
{
|
||||
strncpy(BaseDirectory, dir, 2047);
|
||||
BaseDirectory[2047] = 0;
|
||||
}
|
||||
|
||||
void FCEUI_SetSaveDirectory(char *sav_dir)
|
||||
{
|
||||
strncpy(SaveDirectory, sav_dir, 2047);
|
||||
SaveDirectory[2047] = 0;
|
||||
}
|
||||
|
||||
static char *odirs[FCEUIOD__COUNT] = { 0, 0, 0, 0, 0, 0 }; /* odirs, odors. ^_^ */
|
||||
|
||||
void FCEUI_SetDirOverride(int which, char *n)
|
||||
@@ -75,16 +66,16 @@ char *FCEU_MakeFName(int type, int id1, char *cd1)
|
||||
switch (type)
|
||||
{
|
||||
case FCEUMKF_GGROM:
|
||||
sprintf(tmp, "%s%c%s", BaseDirectory, PS, "gg.rom");
|
||||
fill_pathname_join(tmp, BaseDirectory,
|
||||
"gg.rom", sizeof(tmp));
|
||||
break;
|
||||
case FCEUMKF_FDSROM:
|
||||
sprintf(tmp, "%s%c%s", BaseDirectory, PS, "disksys.rom");
|
||||
fill_pathname_join(tmp, BaseDirectory,
|
||||
"disksys.rom", sizeof(tmp));
|
||||
break;
|
||||
case FCEUMKF_PALETTE:
|
||||
sprintf(tmp, "%s%c%s", BaseDirectory, PS, "nes.pal");
|
||||
break;
|
||||
case FCEUMKF_FDS:
|
||||
sprintf(tmp, "%s%c%s%s", SaveDirectory, PS, FileBase, ".sav");
|
||||
fill_pathname_join(tmp, BaseDirectory,
|
||||
"nes.pal", sizeof(tmp));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -98,46 +89,6 @@ char *FCEU_MakeFName(int type, int id1, char *cd1)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void GetFileBase(const char *f)
|
||||
{
|
||||
const char *tp1, *tp3;
|
||||
|
||||
#if PSS_STYLE == 4
|
||||
tp1 = ((char*)strrchr(f, ':'));
|
||||
#elif PSS_STYLE == 1
|
||||
tp1 = ((char*)strrchr(f, '/'));
|
||||
#else
|
||||
tp1 = ((char*)strrchr(f, '\\'));
|
||||
#if PSS_STYLE != 3
|
||||
tp3 = ((char*)strrchr(f, '/'));
|
||||
if (tp1 < tp3) tp1 = tp3;
|
||||
#endif
|
||||
#endif
|
||||
if (!tp1)
|
||||
{
|
||||
tp1 = f;
|
||||
strcpy(FileBaseDirectory, ".");
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(FileBaseDirectory, f, tp1 - f);
|
||||
FileBaseDirectory[tp1 - f] = 0;
|
||||
tp1++;
|
||||
}
|
||||
|
||||
if (((tp3 = strrchr(f, '.')) != NULL) && (tp3 > tp1))
|
||||
{
|
||||
memcpy(FileBase, tp1, tp3 - tp1);
|
||||
FileBase[tp3 - tp1] = 0;
|
||||
strcpy(FileExt, tp3);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(FileBase, tp1);
|
||||
FileExt[0] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32 uppow2(uint32 n)
|
||||
{
|
||||
int x;
|
||||
|
||||
Reference in New Issue
Block a user