use weakly_canonical in getGameDir and getSaveDir

This commit is contained in:
ConfiG 2023-06-10 15:49:55 +03:00
parent 68357143e8
commit 46fab0e821
No known key found for this signature in database
GPG key ID: 44DA1983F524C11B
2 changed files with 5 additions and 14 deletions
loader/src
loader
platform/windows

View file

@ -7,17 +7,6 @@
using namespace geode::prelude;
namespace {
ghc::filesystem::path weaklyCanonical(ghc::filesystem::path const& path) {
#ifdef GEODE_IS_WINDOWS
// this is std::filesystem intentionally because ghc version doesnt want to work with softlinked directories
return std::filesystem::weakly_canonical(path.string()).string();
#else
return ghc::filesystem::weakly_canonical(path.string()).string();
#endif
}
}
ghc::filesystem::path dirs::getGeodeDir() {
return dirs::getGameDir() / "geode";
}

View file

@ -16,6 +16,8 @@ using namespace geode::prelude;
#include <Geode/utils/web.hpp>
#include <Geode/utils/cocos.hpp>
#include <filesystem>
bool utils::clipboard::write(std::string const& data) {
if (!OpenClipboard(nullptr)) return false;
if (!EmptyClipboard()) {
@ -124,7 +126,7 @@ ghc::filesystem::path dirs::getGameDir() {
GetModuleFileNameW(NULL, buffer.data(), MAX_PATH);
const ghc::filesystem::path path(buffer.data());
return path.parent_path();
return std::filesystem::weakly_canonical(path.parent_path().wstring()).wstring();
}();
return path;
@ -146,11 +148,11 @@ ghc::filesystem::path dirs::getSaveDir() {
auto savePath = appdataPath / executableName;
if (SHCreateDirectoryExW(NULL, savePath.wstring().c_str(), NULL) >= 0) {
return savePath;
return std::filesystem::weakly_canonical(savePath.wstring()).wstring();
}
}
return executablePath.parent_path();
return std::filesystem::weakly_canonical(executablePath.parent_path().wstring()).wstring();
}();
return path;