From 0692e52bb9102510c5b5206422001d8d050a8726 Mon Sep 17 00:00:00 2001 From: Vladyslav Baranovskyi Date: Tue, 4 Jun 2024 11:27:15 +0300 Subject: [PATCH] Using Utils::ReadFile to get contents of the yml file --- openVulkanoCpp/Base/EngineConfiguration.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/openVulkanoCpp/Base/EngineConfiguration.cpp b/openVulkanoCpp/Base/EngineConfiguration.cpp index 169907f..6045606 100644 --- a/openVulkanoCpp/Base/EngineConfiguration.cpp +++ b/openVulkanoCpp/Base/EngineConfiguration.cpp @@ -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 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())