|
|
|
@ -35,11 +35,11 @@ namespace VFS
|
|
|
|
|
return getNormalized(Path::normalizeFilename(name));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Files::IStreamPtr Manager::getNormalized(const std::string& normalizedName) const
|
|
|
|
|
Files::IStreamPtr Manager::getNormalized(std::string_view normalizedName) const
|
|
|
|
|
{
|
|
|
|
|
std::map<std::string, File*>::const_iterator found = mIndex.find(normalizedName);
|
|
|
|
|
const auto found = mIndex.find(normalizedName);
|
|
|
|
|
if (found == mIndex.end())
|
|
|
|
|
throw std::runtime_error("Resource '" + normalizedName + "' not found");
|
|
|
|
|
throw std::runtime_error("Resource '" + std::string(normalizedName) + "' not found");
|
|
|
|
|
return found->second->open();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -70,21 +70,13 @@ namespace VFS
|
|
|
|
|
return found->second->getPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
bool startsWith(std::string_view text, std::string_view start)
|
|
|
|
|
{
|
|
|
|
|
return text.rfind(start, 0) == 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Manager::RecursiveDirectoryRange Manager::getRecursiveDirectoryIterator(std::string_view path) const
|
|
|
|
|
{
|
|
|
|
|
if (path.empty())
|
|
|
|
|
return { mIndex.begin(), mIndex.end() };
|
|
|
|
|
std::string normalized = Path::normalizeFilename(path);
|
|
|
|
|
const auto it = mIndex.lower_bound(normalized);
|
|
|
|
|
if (it == mIndex.end() || !startsWith(it->first, normalized))
|
|
|
|
|
if (it == mIndex.end() || !it->first.starts_with(normalized))
|
|
|
|
|
return { it, it };
|
|
|
|
|
++normalized.back();
|
|
|
|
|
return { it, mIndex.lower_bound(normalized) };
|
|
|
|
|