diff --git a/apps/openmw_test_suite/vfs/testpathutil.cpp b/apps/openmw_test_suite/vfs/testpathutil.cpp index 7b9c9abfb5..6eb84f97d5 100644 --- a/apps/openmw_test_suite/vfs/testpathutil.cpp +++ b/apps/openmw_test_suite/vfs/testpathutil.cpp @@ -72,6 +72,13 @@ namespace VFS::Path EXPECT_EQ(value.value(), "foo/bar/baz"); } + TEST(NormalizedTest, shouldSupportOperatorDivEqualWithStringView) + { + Normalized value("foo/bar"); + value /= std::string_view("BAZ"); + EXPECT_EQ(value.value(), "foo/bar/baz"); + } + TEST(NormalizedTest, changeExtensionShouldReplaceAfterLastDot) { Normalized value("foo/bar.a"); diff --git a/components/l10n/manager.cpp b/components/l10n/manager.cpp index 10cad81587..77474cd3f5 100644 --- a/components/l10n/manager.cpp +++ b/components/l10n/manager.cpp @@ -36,11 +36,13 @@ namespace l10n void Manager::readLangData(const std::string& name, MessageBundles& ctx, const icu::Locale& lang) { - std::string path = "l10n/"; - path.append(name); - path.append("/"); - path.append(lang.getName()); - path.append(".yaml"); + std::string langName(lang.getName()); + langName += ".yaml"; + + VFS::Path::Normalized path("l10n"); + path /= name; + path /= langName; + if (!mVFS->exists(path)) return; diff --git a/components/vfs/pathutil.hpp b/components/vfs/pathutil.hpp index 6e5c5843f3..07e73acfa9 100644 --- a/components/vfs/pathutil.hpp +++ b/components/vfs/pathutil.hpp @@ -187,6 +187,16 @@ namespace VFS::Path return *this; } + Normalized& operator/=(std::string_view value) + { + mValue.reserve(mValue.size() + value.size() + 1); + mValue += separator; + const std::size_t offset = mValue.size(); + mValue += value; + normalizeFilenameInPlace(mValue.begin() + offset, mValue.end()); + return *this; + } + friend bool operator==(const Normalized& lhs, const Normalized& rhs) = default; friend bool operator==(const Normalized& lhs, const auto& rhs) { return lhs.mValue == rhs; }