diff options
author | Arisotura <thetotalworm@gmail.com> | 2019-03-27 04:23:03 +0100 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2019-03-27 04:23:03 +0100 |
commit | 6d7e80b67768d1c14792f5da5ff59b739e2109e6 (patch) | |
tree | 34eaabaf36eb9f37861aa7c1a9f962508b283c37 /src/libui_sdl | |
parent | 5d127f9e555faf227a7736f74ae579df6adee41a (diff) |
move melon_fopen() to Platform.cpp
melon_fopen_local() will need fixoring
Diffstat (limited to 'src/libui_sdl')
-rw-r--r-- | src/libui_sdl/Platform.cpp | 29 | ||||
-rw-r--r-- | src/libui_sdl/main.cpp | 2 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/libui_sdl/Platform.cpp b/src/libui_sdl/Platform.cpp index f739d63..a3619b5 100644 --- a/src/libui_sdl/Platform.cpp +++ b/src/libui_sdl/Platform.cpp @@ -81,6 +81,35 @@ void StopEmu() } +FILE* OpenFile(const char* path, const char* mode) +{ +#ifdef __WIN32__ + + int len = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0); + if (len < 1) return NULL; + WCHAR* fatpath = new WCHAR[len]; + int res = MultiByteToWideChar(CP_UTF8, 0, path, -1, fatpath, len); + if (res != len) { delete[] fatpath; return NULL; } // checkme? + + // this will be more than enough + WCHAR fatmode[4]; + fatmode[0] = mode[0]; + fatmode[1] = mode[1]; + fatmode[2] = mode[2]; + fatmode[3] = 0; + + FILE* ret = _wfopen(fatpath, fatmode); + delete[] fatpath; + return ret; + +#else + + return fopen(path, mode); + +#endif +} + + void* Thread_Create(void (*func)()) { ThreadData* data = new ThreadData; diff --git a/src/libui_sdl/main.cpp b/src/libui_sdl/main.cpp index e4ac78a..4fc6679 100644 --- a/src/libui_sdl/main.cpp +++ b/src/libui_sdl/main.cpp @@ -140,7 +140,7 @@ void GetSavestateName(int slot, char* filename, int len); bool FileExists(const char* name) { - FILE* f = melon_fopen(name, "rb"); + FILE* f = Platform::OpenFile(name, "rb"); if (!f) return false; fclose(f); return true; |