attempt to fix some problems caused by users running desmume out of directories with non-english characters (could manifest as "could not get read/write access to the battery save file")
This commit is contained in:
parent
b2ad722473
commit
48f5a8289d
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "path.h"
|
||||
#include "winutil.h"
|
||||
#include "utils/xstring.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
@ -26,7 +27,7 @@
|
|||
|
||||
char IniName[MAX_PATH];
|
||||
|
||||
char* _hack_alternateModulePath;
|
||||
std::string _hack_alternateModulePathUtf8;
|
||||
|
||||
|
||||
static char vPath[MAX_PATH*2], *szPath;
|
||||
|
@ -53,14 +54,13 @@ void GetINIPath()
|
|||
|
||||
//use an alternate path
|
||||
useModulePath = false;
|
||||
static char userpath[MAX_PATH];
|
||||
SHGetFolderPath(NULL,CSIDL_LOCAL_APPDATA,NULL,0,userpath);
|
||||
_snprintf(vPath,MAX_PATH,"%s\\%s",userpath,"DeSmuME");
|
||||
szPath = vPath;
|
||||
_hack_alternateModulePath = szPath;
|
||||
static wchar_t userpath[MAX_PATH];
|
||||
SHGetFolderPathW(NULL,CSIDL_LOCAL_APPDATA,NULL,0,userpath);
|
||||
std::wstring blah = (std::wstring)userpath + L"\\DeSmuME";
|
||||
_hack_alternateModulePathUtf8 = wcstombs(blah);
|
||||
|
||||
//not so sure about this.. but lets go for it.
|
||||
SetCurrentDirectory(userpath);
|
||||
SetCurrentDirectoryW(blah.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,18 +193,22 @@ void PathInfo::LoadModulePath()
|
|||
{
|
||||
#if defined(HOST_WINDOWS)
|
||||
|
||||
char *p;
|
||||
wchar_t *p;
|
||||
ZeroMemory(pathToModule, sizeof(pathToModule));
|
||||
|
||||
GetModuleFileName(NULL, pathToModule, sizeof(pathToModule));
|
||||
p = pathToModule + lstrlen(pathToModule);
|
||||
while (p >= pathToModule && *p != DIRECTORY_DELIMITER_CHAR) p--;
|
||||
if (++p >= pathToModule) *p = 0;
|
||||
wchar_t wPathToModule[MAX_PATH];
|
||||
GetModuleFileNameW(NULL, wPathToModule, sizeof(wPathToModule));
|
||||
p = wPathToModule + wcslen(wPathToModule);
|
||||
while (p >= wPathToModule && *p != DIRECTORY_DELIMITER_CHAR) p--;
|
||||
if (++p >= wPathToModule) *p = 0;
|
||||
|
||||
extern char* _hack_alternateModulePath;
|
||||
if (_hack_alternateModulePath)
|
||||
auto tmp = wcstombs(wPathToModule);
|
||||
strcpy(pathToModule,tmp.c_str());
|
||||
|
||||
extern std::string _hack_alternateModulePathUtf8;
|
||||
if (!_hack_alternateModulePathUtf8.empty())
|
||||
{
|
||||
strcpy(pathToModule, _hack_alternateModulePath);
|
||||
strcpy(pathToModule, _hack_alternateModulePathUtf8.c_str());
|
||||
}
|
||||
#elif defined(DESMUME_COCOA)
|
||||
std::string pathStr = Path::GetFileDirectoryPath(path);
|
||||
|
|
Loading…
Reference in New Issue