|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
#include "manager.hpp"
|
|
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <cassert>
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
|
|
|
|
|
#include <components/files/conversion.hpp>
|
|
|
|
@ -37,30 +38,30 @@ 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
|
|
|
|
|
{
|
|
|
|
|
assert(Path::isNormalized(normalizedName));
|
|
|
|
|
const auto found = mIndex.find(normalizedName);
|
|
|
|
|
if (found == mIndex.end())
|
|
|
|
|
throw std::runtime_error("Resource '" + std::string(normalizedName) + "' not found");
|
|
|
|
|
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 {};
|
|
|
|
|