diff options
| author | Chris Bessent <lost.dragonist@gmail.com> | 2021-05-01 14:38:10 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-05-01 14:38:10 -0700 |
| commit | bcaceb96373cdd0a8ef420850e5c5719e3c6c809 (patch) | |
| tree | 619513de007f3c34cd337305725d4f37338d9dc8 /src | |
| parent | b7e8e69f4778bc6a8c93967b1d9aa0eca809dd97 (diff) | |
| parent | cc8fb9bd2340607f8d51f5560232f8bb3d41c95f (diff) | |
Merge pull request #1504 from LostDragonist/skipcwd
Ignore "." and ".." in archives
Diffstat (limited to 'src')
| -rw-r--r-- | src/archivefiletree.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/archivefiletree.cpp b/src/archivefiletree.cpp index 1fbf3195..11e165b8 100644 --- a/src/archivefiletree.cpp +++ b/src/archivefiletree.cpp @@ -158,14 +158,14 @@ protected: currentName = std::get<0>(p)[0]; } - // If the name is different, we need to create a directory from what we have + // If the name is different, we need to create a directory from what we have // accumulated: if (currentName != std::get<0>(p)[0]) { // We may or may not have an index here, it depends on the type of archive (some archives list // intermediate non-empty folders, some don't): entries.push_back(std::make_shared<ArchiveFileTreeImpl>(parent, currentName, currentIndex, std::move(currentFiles))); - + currentFiles.clear(); // Back to a valid state. // Reset the index: @@ -200,7 +200,7 @@ protected: if (currentName != "") { entries.push_back(std::make_shared<ArchiveFileTreeImpl>(parent, currentName, currentIndex, std::move(currentFiles))); } - + // Let the parent class sort the entries: return false; } @@ -214,7 +214,7 @@ private: mutable std::vector<File> m_Files; }; -std::shared_ptr<ArchiveFileTree> ArchiveFileTree::makeTree(Archive const& archive) +std::shared_ptr<ArchiveFileTree> ArchiveFileTree::makeTree(Archive const& archive) { auto const& data = archive.getFileList(); @@ -222,9 +222,16 @@ std::shared_ptr<ArchiveFileTree> ArchiveFileTree::makeTree(Archive const& archiv files.reserve(data.size()); for (size_t i = 0; i < data.size(); ++i) { + // Ignore "." and ".." as they're useless and muck things up + if (data[i]->getArchiveFilePath().compare(L".") == 0 || + data[i]->getArchiveFilePath().compare(L"..") == 0) + { + continue; + } + files.push_back(std::make_tuple( - QString::fromStdWString(data[i]->getArchiveFilePath()).replace("\\", "/").split("/", Qt::SkipEmptyParts), - data[i]->isDirectory(), + QString::fromStdWString(data[i]->getArchiveFilePath()).replace("\\", "/").split("/", Qt::SkipEmptyParts), + data[i]->isDirectory(), (int) i)); } |
