Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Common/Cpp/Filesystem/Filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();



Expand Down
7 changes: 6 additions & 1 deletion Common/Cpp/Filesystem/Filesystem_Linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <unistd.h>
#include <limits.h>
#include "FilePath.h"
#include "Filesystem.h"

namespace PokemonAutomation{
namespace Filesystem{
Expand All @@ -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();
}



Expand Down
7 changes: 6 additions & 1 deletion Common/Cpp/Filesystem/Filesystem_Mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <CoreFoundation/CoreFoundation.h>
#include <CoreFoundation/CFBundle.h>
#include "FilePath.h"
#include "Filesystem.h"

namespace PokemonAutomation{
namespace Filesystem{
Expand Down Expand Up @@ -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());
Expand All @@ -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();
}



Expand Down
6 changes: 5 additions & 1 deletion Common/Cpp/Filesystem/Filesystem_Qt.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <QCoreApplication>
#include "FilePath.h"
#include "Filesystem.h"

namespace PokemonAutomation{
namespace Filesystem{
Expand All @@ -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();
}



Expand Down
6 changes: 5 additions & 1 deletion Common/Cpp/Filesystem/Filesystem_Windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <Windows.h>
#include "FilePath.h"
#include "Filesystem.h"

namespace PokemonAutomation{
namespace Filesystem{
Expand All @@ -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();
}



Expand Down
4 changes: 2 additions & 2 deletions SerialPrograms/Source/CommonFramework/GlobalAutoPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}

Expand Down
Loading