Clean up pass
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m55s
CI / Windows Release Package (push) Successful in 3m14s

This commit is contained in:
Aiden
2026-05-12 13:14:52 +10:00
parent 9938a6cc26
commit bc690e2a87
13 changed files with 417 additions and 220 deletions

View File

@@ -7,11 +7,22 @@
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <vector>
#include <windows.h>
namespace RenderCadenceCompositor
{
namespace
{
std::filesystem::path ExecutableDirectory()
{
char path[MAX_PATH] = {};
const DWORD length = GetModuleFileNameA(nullptr, path, static_cast<DWORD>(sizeof(path)));
if (length == 0 || length >= sizeof(path))
return std::filesystem::current_path();
return std::filesystem::path(path).parent_path();
}
std::string ReadTextFile(const std::filesystem::path& path, std::string& error)
{
std::ifstream input(path, std::ios::binary);
@@ -76,6 +87,17 @@ AppConfigProvider::AppConfigProvider() :
{
}
bool AppConfigProvider::LoadDefault(std::string& error)
{
const std::filesystem::path path = FindConfigFile();
if (path.empty())
{
error = "Could not locate config/runtime-host.json from current directory or executable directory.";
return false;
}
return Load(path, error);
}
bool AppConfigProvider::Load(const std::filesystem::path& path, std::string& error)
{
mConfig = DefaultAppConfig();
@@ -183,4 +205,28 @@ void VideoFormatDimensions(const std::string& formatName, unsigned& width, unsig
width = 1920;
height = 1080;
}
std::filesystem::path FindConfigFile(const std::filesystem::path& relativePath)
{
std::vector<std::filesystem::path> starts;
starts.push_back(std::filesystem::current_path());
starts.push_back(ExecutableDirectory());
for (std::filesystem::path start : starts)
{
for (;;)
{
const std::filesystem::path candidate = start / relativePath;
if (std::filesystem::exists(candidate))
return candidate;
const std::filesystem::path parent = start.parent_path();
if (parent.empty() || parent == start)
break;
start = parent;
}
}
return std::filesystem::path();
}
}