diff options
author | elsid <elsid.mail@gmail.com> | 2024-02-22 23:59:23 +0100 |
---|---|---|
committer | elsid <elsid.mail@gmail.com> | 2024-02-24 12:42:02 +0100 |
commit | 92d57d6e46d8d661969e71be5b39ff36113c9141 (patch) | |
tree | 964db90fc671b65a6d1f8a2d991d76f60125a069 | |
parent | 595e42ae43944bed3fd2ee91d35345cc0f40f923 (diff) |
Make Normalized constructor from const char* explicit
-rw-r--r-- | apps/openmw_test_suite/testing_util.hpp | 7 | ||||
-rw-r--r-- | components/vfs/manager.cpp | 5 | ||||
-rw-r--r-- | components/vfs/manager.hpp | 2 | ||||
-rw-r--r-- | components/vfs/pathutil.hpp | 2 |
4 files changed, 15 insertions, 1 deletions
diff --git a/apps/openmw_test_suite/testing_util.hpp b/apps/openmw_test_suite/testing_util.hpp index ad1b0423ef..60367ffbe9 100644 --- a/apps/openmw_test_suite/testing_util.hpp +++ b/apps/openmw_test_suite/testing_util.hpp @@ -2,6 +2,7 @@ #define TESTING_UTIL_H #include <filesystem> +#include <initializer_list> #include <sstream> #include <components/misc/strings/conversion.hpp> @@ -73,6 +74,12 @@ namespace TestingOpenMW return vfs; } + inline std::unique_ptr<VFS::Manager> createTestVFS( + std::initializer_list<std::pair<VFS::Path::NormalizedView, VFS::File*>> files) + { + return createTestVFS(VFS::FileMap(files.begin(), files.end())); + } + #define EXPECT_ERROR(X, ERR_SUBSTR) \ try \ { \ diff --git a/components/vfs/manager.cpp b/components/vfs/manager.cpp index a6add0861a..ef5dd495c9 100644 --- a/components/vfs/manager.cpp +++ b/components/vfs/manager.cpp @@ -57,6 +57,11 @@ namespace VFS return mIndex.find(name) != mIndex.end(); } + bool Manager::exists(Path::NormalizedView name) const + { + return mIndex.find(name) != mIndex.end(); + } + std::string Manager::getArchive(const Path::Normalized& name) const { for (auto it = mArchives.rbegin(); it != mArchives.rend(); ++it) diff --git a/components/vfs/manager.hpp b/components/vfs/manager.hpp index 7598b77e68..955538627f 100644 --- a/components/vfs/manager.hpp +++ b/components/vfs/manager.hpp @@ -43,6 +43,8 @@ namespace VFS /// @note May be called from any thread once the index has been built. bool exists(const Path::Normalized& name) const; + bool exists(Path::NormalizedView name) const; + /// Retrieve a file by name. /// @note Throws an exception if the file can not be found. /// @note May be called from any thread once the index has been built. diff --git a/components/vfs/pathutil.hpp b/components/vfs/pathutil.hpp index aa7cad8524..45355cd129 100644 --- a/components/vfs/pathutil.hpp +++ b/components/vfs/pathutil.hpp @@ -122,7 +122,7 @@ namespace VFS::Path { } - Normalized(const char* value) + explicit Normalized(const char* value) : Normalized(std::string_view(value)) { } |