don't rely on filesystem current_path

This commit is contained in:
altalk23 2023-05-01 14:47:25 +03:00
parent d60782fee1
commit dc96da012d
4 changed files with 18 additions and 12 deletions
loader
launcher/windows
src
loader
platform
mac
windows

View file

@ -17,7 +17,11 @@ int loadGeode(PVOID module) {
}
DWORD WINAPI load(PVOID module) {
auto workingDir = ghc::filesystem::current_path();
std::array<TCHAR, MAX_PATH> szFileName;
GetModuleFileName(NULL, szFileName.data(), MAX_PATH);
ghc::filesystem::path path(szFileName);
auto workingDir = path.parent_path();
auto updatesDir = workingDir / "geode" / "update";
auto resourcesDir = workingDir / "geode" / "resources";

View file

@ -19,7 +19,7 @@ namespace {
}
ghc::filesystem::path dirs::getGameDir() {
return weaklyCanonical(CCFileUtils::sharedFileUtils()->getWritablePath2().c_str());
return utils::file::current_path();
}
ghc::filesystem::path dirs::getSaveDir() {

View file

@ -149,17 +149,14 @@ CCPoint cocos::getMousePos() {
}
ghc::filesystem::path utils::file::current_path() {
// if it's just a slash because for some reason it is
if (ghc::filesystem::current_path().string().size() < 2) {
std::array<char, PATH_MAX> gddir;
std::array<char, PATH_MAX> gddir;
uint32_t out = PATH_MAX;
_NSGetExecutablePath(gddir.data(), &out);
uint32_t out = PATH_MAX;
_NSGetExecutablePath(gddir.data(), &out);
ghc::filesystem::path gdpath = gddir.data();
ghc::filesystem::current_path(gdpath.parent_path().parent_path());
}
return ghc::filesystem::current_path();
ghc::filesystem::path gdpath = gddir.data();
auto currentPath = gdpath.parent_path().parent_path();
return currentPath;
}
#endif

View file

@ -116,7 +116,12 @@ CCPoint cocos::getMousePos() {
}
ghc::filesystem::path utils::file::current_path() {
return ghc::filesystem::current_path();
std::array<TCHAR, MAX_PATH> szFileName;
GetModuleFileName(NULL, szFileName.data(), MAX_PATH);
ghc::filesystem::path path(szFileName);
auto currentPath = path.parent_path();
return currentPath;
}
#endif