Return Path::Normalized from RecursiveDirectoryIterator

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

@ -113,9 +113,9 @@ void readVFS(std::unique_ptr<VFS::Archive>&& archive, const std::filesystem::pat
for (const auto& name : vfs.getRecursiveDirectoryIterator("")) for (const auto& name : vfs.getRecursiveDirectoryIterator(""))
{ {
if (isNIF(name)) if (isNIF(name.value()))
{ {
readNIF(archivePath, name, &vfs, quiet); readNIF(archivePath, name.value(), &vfs, quiet);
} }
} }

@ -30,18 +30,18 @@ void CSMWorld::Resources::recreate(const VFS::Manager* vfs, const char* const* e
for (const auto& filepath : vfs->getRecursiveDirectoryIterator("")) for (const auto& filepath : vfs->getRecursiveDirectoryIterator(""))
{ {
if (filepath.size() < baseSize + 1 || filepath.substr(0, baseSize) != mBaseDirectory const std::string_view view = filepath.view();
|| (filepath[baseSize] != '/' && filepath[baseSize] != '\\')) if (view.size() < baseSize + 1 || !view.starts_with(mBaseDirectory) || view[baseSize] != '/')
continue; continue;
if (extensions) if (extensions)
{ {
std::string::size_type extensionIndex = filepath.find_last_of('.'); const auto extensionIndex = view.find_last_of('.');
if (extensionIndex == std::string::npos) if (extensionIndex == std::string_view::npos)
continue; continue;
std::string extension = filepath.substr(extensionIndex + 1); std::string_view extension = view.substr(extensionIndex + 1);
int i = 0; int i = 0;
@ -53,10 +53,9 @@ void CSMWorld::Resources::recreate(const VFS::Manager* vfs, const char* const* e
continue; continue;
} }
std::string file = filepath.substr(baseSize + 1); std::string file(view.substr(baseSize + 1));
mFiles.push_back(file); mFiles.push_back(file);
std::replace(file.begin(), file.end(), '\\', '/'); mIndex.emplace(std::move(file), static_cast<int>(mFiles.size()) - 1);
mIndex.insert(std::make_pair(Misc::StringUtils::lowerCase(file), static_cast<int>(mFiles.size()) - 1));
} }
} }

@ -16,9 +16,9 @@ namespace VFS
{ {
} }
const std::string& operator*() const { return mIt->first.value(); } const Path::Normalized& operator*() const { return mIt->first; }
const std::string* operator->() const { return &mIt->first.value(); } const Path::Normalized* operator->() const { return &mIt->first; }
RecursiveDirectoryIterator& operator++() RecursiveDirectoryIterator& operator++()
{ {

Loading…
Cancel
Save