mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 15:19:53 -06:00
fix configfile loading under Windows, for when it checks AppData
by making it actually, you know, build the complete file path hopefully that fixes that crash bug, but I couldn't reproduce it after touching the code some. heisenbugs are lots of fun
This commit is contained in:
@ -129,7 +129,20 @@ FILE* GetConfigFile(const char* fileName, const char* permissions)
|
|||||||
SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &appDataPath);
|
SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &appDataPath);
|
||||||
if (!appDataPath)
|
if (!appDataPath)
|
||||||
return NULL;
|
return NULL;
|
||||||
CoTaskMemRealloc(appDataPath, (wcslen(appDataPath)+9+strlen(fileName)+1)*sizeof(WCHAR));
|
|
||||||
|
const WCHAR* appdir = L"\\melonDS\\";
|
||||||
|
|
||||||
|
int fnlen = MultiByteToWideChar(CP_UTF8, 0, fileName, -1, NULL, 0);
|
||||||
|
if (fnlen < 1) return NULL;
|
||||||
|
WCHAR* wfileName = new WCHAR[fnlen];
|
||||||
|
int res = MultiByteToWideChar(CP_UTF8, 0, fileName, -1, wfileName, fnlen);
|
||||||
|
if (res != fnlen) { delete[] wfileName; return NULL; } // checkme?
|
||||||
|
|
||||||
|
int pos = wcslen(appDataPath);
|
||||||
|
CoTaskMemRealloc(appDataPath, (pos+wcslen(appdir)+fnlen+1)*sizeof(WCHAR));
|
||||||
|
|
||||||
|
wcscpy(&appDataPath[pos], appdir);
|
||||||
|
wcscpy(&appDataPath[pos+9], wfileName);
|
||||||
|
|
||||||
// this will be more than enough
|
// this will be more than enough
|
||||||
WCHAR fatperm[4];
|
WCHAR fatperm[4];
|
||||||
@ -140,6 +153,7 @@ FILE* GetConfigFile(const char* fileName, const char* permissions)
|
|||||||
|
|
||||||
f = _wfopen(appDataPath, fatperm);
|
f = _wfopen(appDataPath, fatperm);
|
||||||
CoTaskMemFree(appDataPath);
|
CoTaskMemFree(appDataPath);
|
||||||
|
delete[] wfileName;
|
||||||
if (f) return f;
|
if (f) return f;
|
||||||
#else
|
#else
|
||||||
// Now check XDG_CONFIG_HOME
|
// Now check XDG_CONFIG_HOME
|
||||||
|
Reference in New Issue
Block a user