1 parent
ab01c2c469
commit
1bdc60b8d2
5 files changed
+54
-39
No files matched your search
@@ -2,18 +2,12 @@
|
||||
|
||||
#include <glaze/glaze.hpp>
|
||||
|
||||
#include "../helpers/FsUtils.hpp"
|
||||
#include "../GlobalState.hpp"
|
||||
|
||||
static std::string readFileAsText(const std::string& path) {
|
||||
std::ifstream ifs(path);
|
||||
auto res = std::string((std::istreambuf_iterator<char>(ifs)), (std::istreambuf_iterator<char>()));
|
||||
if (res.back() == '\n')
|
||||
res.pop_back();
|
||||
return res;
|
||||
}
|
||||
|
||||
CConfig::CConfig() {
|
||||
auto json = glz::read_jsonc<SConfig>(readFileAsText(g_pGlobalState->cwd + "/" + g_pGlobalState->configPath));
|
||||
auto json = glz::read_jsonc<SConfig>(
|
||||
NFsUtils::readFileAsString(NFsUtils::isAbsolute(g_pGlobalState->configPath) ? g_pGlobalState->configPath : g_pGlobalState->cwd + "/" + g_pGlobalState->configPath).value());
|
||||
|
||||
if (!json.has_value())
|
||||
throw std::runtime_error("No config / bad config format");
|
||||
|
||||
Reference in new issue
Block a user