Feature request; allow loading prefs.bin relatively
This commit is contained in:
parent
9f3bffd4dd
commit
d75b7c0023
10
SDL/main.c
10
SDL/main.c
@ -11,6 +11,7 @@
|
||||
|
||||
#ifndef _WIN32
|
||||
#define AUDIO_FREQUENCY 96000
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <Windows.h>
|
||||
/* Windows (well, at least my VM) can't handle 96KHz sound well :( */
|
||||
@ -686,9 +687,12 @@ int main(int argc, char **argv)
|
||||
|
||||
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||
|
||||
char *prefs_dir = SDL_GetPrefPath("", "SameBoy");
|
||||
snprintf(prefs_path, sizeof(prefs_path) - 1, "%sprefs.bin", prefs_dir);
|
||||
SDL_free(prefs_dir);
|
||||
strcpy(prefs_path, resource_path("prefs.bin"));
|
||||
if (access(prefs_path, R_OK | W_OK) != 0) {
|
||||
char *prefs_dir = SDL_GetPrefPath("", "SameBoy");
|
||||
snprintf(prefs_path, sizeof(prefs_path) - 1, "%sprefs.bin", prefs_dir);
|
||||
SDL_free(prefs_dir);
|
||||
}
|
||||
|
||||
FILE *prefs_file = fopen(prefs_path, "rb");
|
||||
if (prefs_file) {
|
||||
|
@ -2,6 +2,10 @@
|
||||
#include_next <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int access(const char *filename, int mode);
|
||||
#define R_OK 2
|
||||
#define W_OK 4
|
||||
|
||||
#ifndef __MINGW32__
|
||||
#ifndef __LIBRETRO__
|
||||
static inline int vasprintf(char **str, const char *fmt, va_list args)
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <winnls.h>
|
||||
#include <io.h>
|
||||
|
||||
FILE *fopen(const char *filename, const char *mode)
|
||||
{
|
||||
@ -12,3 +13,12 @@ FILE *fopen(const char *filename, const char *mode)
|
||||
|
||||
return _wfopen(w_filename, w_mode);
|
||||
}
|
||||
|
||||
int access(const char *filename, int mode)
|
||||
{
|
||||
wchar_t w_filename[MAX_PATH] = {0,};
|
||||
MultiByteToWideChar(CP_UTF8, 0, filename, -1, w_filename, sizeof(w_filename) / sizeof(w_filename[0]));
|
||||
|
||||
return _waccess(w_filename, mode);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user