diff --git a/src/Application.cpp b/src/Application.cpp index 8c47bd05..4d62ba75 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -154,17 +154,16 @@ void Application::shutdown() { } void Application::loadProjectConfiguration() { - auto currentPath = std::filesystem::current_path().string(); - auto jsonConfigFile = QFile(QString::fromStdString(currentPath + "/bloom.json")); + auto jsonConfigFile = QFile(QString::fromStdString(Paths::projectConfigPath())); if (!jsonConfigFile.exists()) { throw InvalidConfig("Bloom configuration file (bloom.json) not found. Working directory: " - + currentPath); + + Paths::projectDirPath()); } if (!jsonConfigFile.open(QIODevice::ReadOnly)) { throw InvalidConfig("Failed to load Bloom configuration file (bloom.json) Working directory: " - + currentPath); + + Paths::projectDirPath()); } auto jsonObject = QJsonDocument::fromJson(jsonConfigFile.readAll()).object(); diff --git a/src/Helpers/Paths.hpp b/src/Helpers/Paths.hpp index bcbc4475..6cf6b876 100644 --- a/src/Helpers/Paths.hpp +++ b/src/Helpers/Paths.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace Bloom { @@ -19,10 +20,27 @@ namespace Bloom * * @return */ - static inline std::string resourcesDirPath() { + static std::string resourcesDirPath() { return Paths::applicationDirPath() + "/../resources/"; } + /** + * Returns the path to the current project's directory (the working directory, from which Bloom was run) + * + * @return + */ + static std::string projectDirPath() { + return std::filesystem::current_path().string(); + } + + /** + * Returns the path to the current project's configuration file (bloom.json). + * + * @return + */ + static std::string projectConfigPath() { + return std::filesystem::current_path().string() + "/bloom.json"; + } /** * Returns the path to Bloom's compiled resources. *