From 9279138fb0c9e138846b259ea0e566f4c8ae01d7 Mon Sep 17 00:00:00 2001 From: elsid Date: Tue, 16 Jan 2024 23:55:42 +0100 Subject: [PATCH] Accept normalized path by VFS::Manager functions --- components/vfs/manager.cpp | 13 ++++++------- components/vfs/manager.hpp | 7 ++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/components/vfs/manager.cpp b/components/vfs/manager.cpp index 1bf789402d..a6add0861a 100644 --- a/components/vfs/manager.cpp +++ b/components/vfs/manager.cpp @@ -38,9 +38,9 @@ namespace VFS archive->listResources(mIndex); } - Files::IStreamPtr Manager::get(std::string_view name) const + Files::IStreamPtr Manager::get(const Path::Normalized& name) const { - return getNormalized(Path::normalizeFilename(name)); + return getNormalized(name); } Files::IStreamPtr Manager::getNormalized(std::string_view normalizedName) const @@ -52,17 +52,16 @@ namespace VFS return found->second->open(); } - bool Manager::exists(std::string_view name) const + bool Manager::exists(const Path::Normalized& name) const { - return mIndex.find(Path::normalizeFilename(name)) != mIndex.end(); + return mIndex.find(name) != mIndex.end(); } - std::string Manager::getArchive(std::string_view name) const + std::string Manager::getArchive(const Path::Normalized& name) const { - std::string normalized = Path::normalizeFilename(name); for (auto it = mArchives.rbegin(); it != mArchives.rend(); ++it) { - if ((*it)->contains(normalized)) + if ((*it)->contains(name)) return (*it)->getDescription(); } return {}; diff --git a/components/vfs/manager.hpp b/components/vfs/manager.hpp index 05990a8607..7598b77e68 100644 --- a/components/vfs/manager.hpp +++ b/components/vfs/manager.hpp @@ -10,6 +10,7 @@ #include #include "filemap.hpp" +#include "pathutil.hpp" namespace VFS { @@ -40,19 +41,19 @@ namespace VFS /// Does a file with this name exist? /// @note May be called from any thread once the index has been built. - bool exists(std::string_view name) const; + bool exists(const Path::Normalized& 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. - Files::IStreamPtr get(std::string_view name) const; + Files::IStreamPtr get(const Path::Normalized& name) const; /// Retrieve a file by name (name is already normalized). /// @note Throws an exception if the file can not be found. /// @note May be called from any thread once the index has been built. Files::IStreamPtr getNormalized(std::string_view normalizedName) const; - std::string getArchive(std::string_view name) const; + std::string getArchive(const Path::Normalized& name) const; /// Recursively iterate over the elements of the given path /// In practice it return all files of the VFS starting with the given path