move melon_fopen() to Platform.cpp

melon_fopen_local() will need fixoring
This commit is contained in:
Arisotura
2019-03-27 04:23:03 +01:00
parent 5d127f9e55
commit 6d7e80b677
8 changed files with 44 additions and 33 deletions

View File

@ -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;

View File

@ -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;