Using Utils::ReadFile to get contents of the yml file
This commit is contained in:
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user