diff --git a/Common/Cpp/Filesystem/Filesystem.h b/Common/Cpp/Filesystem/Filesystem.h index 63b7f3f2c2..30cadb0343 100644 --- a/Common/Cpp/Filesystem/Filesystem.h +++ b/Common/Cpp/Filesystem/Filesystem.h @@ -59,10 +59,19 @@ void rename(const Path& old_path, const Path& new_path); // If an error occurs, set `ec`. Execute `ec.clear()` if no errors occur. void rename(const Path& old_path, const Path& new_path, std::error_code& ec); + +// The current working directory. Path current_path(); +// The path to the actual binary that is running. Path application_binary_path(); -Path application_working_path(); + +// Path to where the application is installed. +// All immutable resources are relative to this. +Path application_install_path(); + +// Path to where the application saves its output/settings. +Path application_scratch_path(); diff --git a/Common/Cpp/Filesystem/Filesystem_Linux.h b/Common/Cpp/Filesystem/Filesystem_Linux.h index f2264c22ef..54d8a8ed84 100644 --- a/Common/Cpp/Filesystem/Filesystem_Linux.h +++ b/Common/Cpp/Filesystem/Filesystem_Linux.h @@ -7,6 +7,7 @@ #include #include #include "FilePath.h" +#include "Filesystem.h" namespace PokemonAutomation{ namespace Filesystem{ @@ -20,9 +21,13 @@ Path application_binary_path(){ } return Path(); } -Path application_working_path(){ +Path application_install_path(){ + // TODO: This is just a placeholder. return application_binary_path(); } +Path application_scratch_path(){ + return current_path(); +} diff --git a/Common/Cpp/Filesystem/Filesystem_Mac.h b/Common/Cpp/Filesystem/Filesystem_Mac.h index 95636fc1cb..e6cbc614f4 100644 --- a/Common/Cpp/Filesystem/Filesystem_Mac.h +++ b/Common/Cpp/Filesystem/Filesystem_Mac.h @@ -10,6 +10,7 @@ #include #include #include "FilePath.h" +#include "Filesystem.h" namespace PokemonAutomation{ namespace Filesystem{ @@ -53,7 +54,7 @@ std::filesystem::path CFString_to_path(CFStringRef cfString) { return {}; } -Path application_working_path(){ +Path application_install_path(){ // Use CFBundle to find the .app bundle path. // Change working directory to the folder that hosts the .app bundle. CFURLRef bundleURL = CFBundleCopyBundleURL(CFBundleGetMainBundle()); @@ -72,6 +73,10 @@ Path application_working_path(){ // Fallback return application_binary_path(); } +Path application_scratch_path(){ + // TODO: This is just a placeholder. + return current_path(); +} diff --git a/Common/Cpp/Filesystem/Filesystem_Qt.h b/Common/Cpp/Filesystem/Filesystem_Qt.h index c9e3e7b0f1..08c907780c 100644 --- a/Common/Cpp/Filesystem/Filesystem_Qt.h +++ b/Common/Cpp/Filesystem/Filesystem_Qt.h @@ -6,6 +6,7 @@ #include #include "FilePath.h" +#include "Filesystem.h" namespace PokemonAutomation{ namespace Filesystem{ @@ -15,9 +16,12 @@ Path application_binary_path(){ QString application_dir_path = qApp->applicationDirPath(); return Path(application_dir_path.toStdString()); } -Path application_working_path(){ +Path application_install_path(){ return application_binary_path(); } +Path application_scratch_path(){ + return current_path(); +} diff --git a/Common/Cpp/Filesystem/Filesystem_Windows.h b/Common/Cpp/Filesystem/Filesystem_Windows.h index ddfbdb576e..ff504c5778 100644 --- a/Common/Cpp/Filesystem/Filesystem_Windows.h +++ b/Common/Cpp/Filesystem/Filesystem_Windows.h @@ -6,6 +6,7 @@ #include #include "FilePath.h" +#include "Filesystem.h" namespace PokemonAutomation{ namespace Filesystem{ @@ -16,9 +17,12 @@ Path application_binary_path(){ GetModuleFileNameW(nullptr, buffer, MAX_PATH); return std::filesystem::path(buffer).parent_path(); } -Path application_working_path(){ +Path application_install_path(){ return application_binary_path(); } +Path application_scratch_path(){ + return current_path(); +} diff --git a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp index 9057c3cbb8..21605cca11 100644 --- a/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp +++ b/SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp @@ -99,7 +99,7 @@ Filesystem::Path get_application_base_dir_path(){ } } #endif - return Filesystem::application_working_path(); + return Filesystem::application_install_path(); } std::string get_resource_path(){ // Find the resource directory. @@ -167,7 +167,7 @@ std::string get_runtime_base_path(){ QDir().mkpath(appSupportPath); return appSupportPath.toStdString() + "/"; #else - return "./"; + return Filesystem::application_scratch_path().string_slash_normalized() + "/"; #endif }