From b55993294a249121ced5e5a64e3082edf945095b Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Sun, 25 May 2025 01:20:20 -0500 Subject: [PATCH] [studio/modlib] Fix headerizeConfigFile to handle slashes in file name --- src/olympic/studio/modlib/include/studio/configio.hpp | 8 ++++---- src/olympic/studio/modlib/src/configio.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/olympic/studio/modlib/include/studio/configio.hpp b/src/olympic/studio/modlib/include/studio/configio.hpp index b155b3a6..e0b79fd1 100644 --- a/src/olympic/studio/modlib/include/studio/configio.hpp +++ b/src/olympic/studio/modlib/include/studio/configio.hpp @@ -30,7 +30,7 @@ inline ox::String slashesToPct(ox::StringViewCR str) noexcept { } [[nodiscard]] -ox::String configPath(keel::Context const&kctx) noexcept; +ox::String configPath(keel::Context const &kctx) noexcept; template ox::Result readConfig(keel::Context &kctx, ox::StringViewCR name) noexcept { @@ -61,7 +61,7 @@ ox::Result readConfig(keel::Context &kctx) noexcept { } template -ox::Error writeConfig(keel::Context &kctx, ox::StringViewCR name, T const&data) noexcept { +ox::Error writeConfig(keel::Context &kctx, ox::StringViewCR name, T const &data) noexcept { oxAssert(name != "", "Config type has no TypeName"); auto const path = ox::sfmt("/{}.json", detail::slashesToPct(name)); ox::PassThroughFS fs(configPath(kctx)); @@ -79,7 +79,7 @@ ox::Error writeConfig(keel::Context &kctx, ox::StringViewCR name, T const&data) } template -ox::Error writeConfig(keel::Context &kctx, T const&data) noexcept { +ox::Error writeConfig(keel::Context &kctx, T const &data) noexcept { constexpr auto TypeName = ox::requireModelTypeName(); return writeConfig(kctx, TypeName, data); } @@ -120,7 +120,7 @@ void editConfig(keel::Context &kctx, Func f) noexcept { */ template ox::Error headerizeConfigFile(keel::Context &kctx, ox::StringViewCR name = ox::ModelTypeName_v) noexcept { - auto const path = ox::sfmt("/{}.json", name); + auto const path = ox::sfmt("/{}.json", detail::slashesToPct(name)); ox::PassThroughFS fs(configPath(kctx)); OX_REQUIRE_M(buff, fs.read(path)); OX_REQUIRE_M(cv1, ox::readOC(buff)); diff --git a/src/olympic/studio/modlib/src/configio.cpp b/src/olympic/studio/modlib/src/configio.cpp index af3b59c0..a136298d 100644 --- a/src/olympic/studio/modlib/src/configio.cpp +++ b/src/olympic/studio/modlib/src/configio.cpp @@ -23,7 +23,7 @@ constexpr auto ConfigDir = [] { } }(); -ox::String configPath(keel::Context const&ctx) noexcept { +ox::String configPath(keel::Context const &ctx) noexcept { auto const homeDir = std::getenv(ox::defines::OS == ox::OS::Windows ? "USERPROFILE" : "HOME"); return ox::sfmt(ConfigDir, homeDir, ctx.appName); }