Accept normalized path by VFS::Manager functions

ini_importer_tests
elsid 12 months ago
parent d549cfd66b
commit 9279138fb0
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625

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

@ -10,6 +10,7 @@
#include <vector>
#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

Loading…
Cancel
Save