Using Utils::ReadFile to get contents of the yml file

This commit is contained in:
Vladyslav Baranovskyi
2024-06-04 11:27:15 +03:00
parent e17e8c2947
commit 0692e52bb9

View File

@@ -11,6 +11,7 @@
#include "EngineConfiguration.hpp"
#include "IO/AppFolders.hpp"
#include "Utils.hpp"
namespace OpenVulkano
{
@@ -23,20 +24,12 @@ namespace OpenVulkano
EngineConfiguration::EngineConfiguration()
{
const std::string filePath = AppFolders::GetAppConfigHomeDir().string() + "/EngineConfig.yml";
std::ifstream file(filePath);
if (!file.is_open())
{
const std::string filePath = (AppFolders::GetAppConfigHomeDir() / "EngineConfig.yml").string();
Array<char> fileContents = Utils::ReadFile(filePath, true);
if(fileContents.Size() == 0)
return;
}
file.seekg(0, std::ios::end);
size_t size = file.tellg();
std::string buffer(size, ' ');
file.seekg(0);
file.read(buffer.data(), size);
ryml::Tree tree = ryml::parse_in_arena(ryml::to_csubstr(buffer));
ryml::Tree tree = ryml::parse_in_arena(ryml::to_csubstr(fileContents.Data()));
ryml::NodeRef root = tree.rootref();
if (root.has_child(NUM_THREADS_STR) && root[NUM_THREADS_STR].val().is_integer())