mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-23 14:19:55 -06:00
move melon_fopen() to Platform.cpp
melon_fopen_local() will need fixoring
This commit is contained in:
@ -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;
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user