summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChris Bessent <lost.dragonist@gmail.com>2021-04-29 01:29:38 -0700
committerChris Bessent <lost.dragonist@gmail.com>2021-04-29 01:29:38 -0700
commitcc8fb9bd2340607f8d51f5560232f8bb3d41c95f (patch)
tree2cef85dfe903ad7f3755306589a31a7e07ea3a4f /src
parent40a4bf1e3a25d98da481c6807e327f036a9a33e6 (diff)
Ignore "." and ".." in archives
Diffstat (limited to 'src')
-rw-r--r--src/archivefiletree.cpp19
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));
}