[studio/modlib] Fix headerizeConfigFile to handle slashes in file name
All checks were successful
Build / build (push) Successful in 1m12s

This commit is contained in:
Gary Talent 2025-05-25 01:20:20 -05:00
parent d8f847d707
commit b55993294a
2 changed files with 5 additions and 5 deletions

View File

@ -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<typename T>
ox::Result<T> readConfig(keel::Context &kctx, ox::StringViewCR name) noexcept {
@ -61,7 +61,7 @@ ox::Result<T> readConfig(keel::Context &kctx) noexcept {
}
template<typename T>
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<typename T>
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<T>();
return writeConfig(kctx, TypeName, data);
}
@ -120,7 +120,7 @@ void editConfig(keel::Context &kctx, Func f) noexcept {
*/
template<typename T>
ox::Error headerizeConfigFile(keel::Context &kctx, ox::StringViewCR name = ox::ModelTypeName_v<T>) 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<T>(buff));

View File

@ -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);
}