Defined paths in Paths helper class
This commit is contained in:
@@ -154,17 +154,16 @@ void Application::shutdown() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Application::loadProjectConfiguration() {
|
void Application::loadProjectConfiguration() {
|
||||||
auto currentPath = std::filesystem::current_path().string();
|
auto jsonConfigFile = QFile(QString::fromStdString(Paths::projectConfigPath()));
|
||||||
auto jsonConfigFile = QFile(QString::fromStdString(currentPath + "/bloom.json"));
|
|
||||||
|
|
||||||
if (!jsonConfigFile.exists()) {
|
if (!jsonConfigFile.exists()) {
|
||||||
throw InvalidConfig("Bloom configuration file (bloom.json) not found. Working directory: "
|
throw InvalidConfig("Bloom configuration file (bloom.json) not found. Working directory: "
|
||||||
+ currentPath);
|
+ Paths::projectDirPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!jsonConfigFile.open(QIODevice::ReadOnly)) {
|
if (!jsonConfigFile.open(QIODevice::ReadOnly)) {
|
||||||
throw InvalidConfig("Failed to load Bloom configuration file (bloom.json) Working directory: "
|
throw InvalidConfig("Failed to load Bloom configuration file (bloom.json) Working directory: "
|
||||||
+ currentPath);
|
+ Paths::projectDirPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto jsonObject = QJsonDocument::fromJson(jsonConfigFile.readAll()).object();
|
auto jsonObject = QJsonDocument::fromJson(jsonConfigFile.readAll()).object();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
namespace Bloom
|
namespace Bloom
|
||||||
{
|
{
|
||||||
@@ -19,10 +20,27 @@ namespace Bloom
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static inline std::string resourcesDirPath() {
|
static std::string resourcesDirPath() {
|
||||||
return Paths::applicationDirPath() + "/../resources/";
|
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.
|
* Returns the path to Bloom's compiled resources.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user