summaryrefslogtreecommitdiff
path: root/Libraries/LibCore/DirIterator.cpp
diff options
context:
space:
mode:
authorShannon Booth <shannon.ml.booth@gmail.com>2020-02-15 13:06:08 +1300
committerAndreas Kling <kling@serenityos.org>2020-02-15 11:40:05 +0100
commit6764b777885e687e4c1e885d6ce557e61fd16685 (patch)
treee2968b1933a2f02c16926daa7507627df9342edf /Libraries/LibCore/DirIterator.cpp
parent3879d752190018fc06cb34251c22ad6273cab8a4 (diff)
downloadserenity-6764b777885e687e4c1e885d6ce557e61fd16685.zip
LibCore: Add SkipParentAndBaseDir flag in DirIterator
Sometimes we may want to iterate over dotfiles but not include the parent or base directory
Diffstat (limited to 'Libraries/LibCore/DirIterator.cpp')
-rw-r--r--Libraries/LibCore/DirIterator.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/Libraries/LibCore/DirIterator.cpp b/Libraries/LibCore/DirIterator.cpp
index f009d6c9f3..b2f2dcea9a 100644
--- a/Libraries/LibCore/DirIterator.cpp
+++ b/Libraries/LibCore/DirIterator.cpp
@@ -67,6 +67,9 @@ bool DirIterator::advance_next()
if (m_flags & Flags::SkipDots && m_next.starts_with('.'))
continue;
+ if (m_flags & Flags::SkipParentAndBaseDir && (m_next == "." || m_next == ".."))
+ continue;
+
return !m_next.is_empty();
}
}