From 8126175eaa9bb4814cf25beed89839aea99abf25 Mon Sep 17 00:00:00 2001 From: HJfod <60038575+HJfod@users.noreply.github.com> Date: Wed, 30 Nov 2022 18:37:15 +0200 Subject: [PATCH] remove geodeRoot --- loader/include/Geode/utils/file.hpp | 1 - loader/src/loader/Loader.cpp | 2 +- loader/src/platform/ios/InternalLoader.cpp | 9 +++++---- loader/src/platform/ios/util.mm | 7 ------- loader/src/platform/mac/util.mm | 7 ------- loader/src/platform/windows/util.cpp | 4 ---- loader/src/ui/internal/settings/GeodeSettingNode.cpp | 4 +++- 7 files changed, 9 insertions(+), 25 deletions(-) diff --git a/loader/include/Geode/utils/file.hpp b/loader/include/Geode/utils/file.hpp index 8089a072..2d75fd7e 100644 --- a/loader/include/Geode/utils/file.hpp +++ b/loader/include/Geode/utils/file.hpp @@ -81,7 +81,6 @@ namespace geode::utils::file { */ GEODE_DLL Result<> unzipTo(ghc::filesystem::path const& from, ghc::filesystem::path const& to); - GEODE_DLL ghc::filesystem::path geodeRoot(); GEODE_DLL bool openFolder(ghc::filesystem::path const& path); enum class PickMode { diff --git a/loader/src/loader/Loader.cpp b/loader/src/loader/Loader.cpp index a3d0e66f..d5ff4bcf 100644 --- a/loader/src/loader/Loader.cpp +++ b/loader/src/loader/Loader.cpp @@ -411,7 +411,7 @@ ghc::filesystem::path Loader::getSaveDirectory() const { } ghc::filesystem::path Loader::getGeodeDirectory() const { - return geode::utils::file::geodeRoot() / GEODE_DIRECTORY; + return this->getGameDirectory() / GEODE_DIRECTORY; } ghc::filesystem::path Loader::getGeodeSaveDirectory() const { diff --git a/loader/src/platform/ios/InternalLoader.cpp b/loader/src/platform/ios/InternalLoader.cpp index 86dfd252..c94f458f 100644 --- a/loader/src/platform/ios/InternalLoader.cpp +++ b/loader/src/platform/ios/InternalLoader.cpp @@ -1,10 +1,11 @@ #include -#include -#include -#include #ifdef GEODE_IS_IOS +#include +#include +#include +#include #include #include #include @@ -16,7 +17,7 @@ void InternalLoader::platformMessageBox(char const* title, std::string const& in void InternalLoader::openPlatformConsole() { ghc::filesystem::path(getpwuid(getuid())->pw_dir); freopen( - ghc::filesystem::path(utils::file::geodeRoot() / "geode_log.txt").string().c_str(), "w", + ghc::filesystem::path(Loader::get()->getGeodeDirectory() / "geode_log.txt").string().c_str(), "w", stdout ); InternalLoader::m_platformConsoleOpen = true; diff --git a/loader/src/platform/ios/util.mm b/loader/src/platform/ios/util.mm index 21f36ebb..faa9ba3c 100644 --- a/loader/src/platform/ios/util.mm +++ b/loader/src/platform/ios/util.mm @@ -19,13 +19,6 @@ std::string utils::clipboard::read() { return std::string([[UIPasteboard generalPasteboard].string UTF8String]); } -ghc::filesystem::path utils::file::geodeRoot() { - return ghc::filesystem::path([[[NSFileManager defaultManager] - URLsForDirectory:NSDocumentDirectory - inDomains:NSUserDomainMask] lastObject] - .path.UTF8String); -} - void utils::web::openLinkInBrowser(std::string const& url) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithUTF8String:url.c_str()]]]; diff --git a/loader/src/platform/mac/util.mm b/loader/src/platform/mac/util.mm index 91de55cc..4cf720ad 100644 --- a/loader/src/platform/mac/util.mm +++ b/loader/src/platform/mac/util.mm @@ -27,13 +27,6 @@ std::string utils::clipboard::read() { return std::string(clipboard); } -ghc::filesystem::path utils::file::geodeRoot() { - char cwd[PATH_MAX]; - getcwd(cwd, sizeof(cwd)); - // utils::clipboard::write(cwd); - return ghc::filesystem::path(cwd); -} - bool utils::file::openFolder(ghc::filesystem::path const& path) { NSURL* fileURL = [NSURL fileURLWithPath:[NSString stringWithUTF8String:path.string().c_str()]]; NSURL* folderURL = [fileURL URLByDeletingLastPathComponent]; diff --git a/loader/src/platform/windows/util.cpp b/loader/src/platform/windows/util.cpp index ca4dce37..3dd1d35f 100644 --- a/loader/src/platform/windows/util.cpp +++ b/loader/src/platform/windows/util.cpp @@ -70,10 +70,6 @@ std::string utils::clipboard::read() { return text; } -ghc::filesystem::path utils::file::geodeRoot() { - return ghc::filesystem::path(CCFileUtils::sharedFileUtils()->getWritablePath2().c_str()); -} - bool utils::file::openFolder(ghc::filesystem::path const& path) { ShellExecuteA(NULL, "open", path.string().c_str(), NULL, NULL, SW_SHOWDEFAULT); return true; diff --git a/loader/src/ui/internal/settings/GeodeSettingNode.cpp b/loader/src/ui/internal/settings/GeodeSettingNode.cpp index ef3a7546..c20c6ad7 100644 --- a/loader/src/ui/internal/settings/GeodeSettingNode.cpp +++ b/loader/src/ui/internal/settings/GeodeSettingNode.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include // BoolSettingNode @@ -120,7 +122,7 @@ void FileSettingNode::onPickFile(CCObject*) { if (auto path = file::pickFile( file::PickMode::OpenFile, { - file::geodeRoot(), + Loader::get()->getGameDirectory(), setting->getFileFilters().value_or(std::vector()) } )) {