diff options
author | Shannon Booth <shannon.ml.booth@gmail.com> | 2020-02-15 13:06:08 +1300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-15 11:40:05 +0100 |
commit | 6764b777885e687e4c1e885d6ce557e61fd16685 (patch) | |
tree | e2968b1933a2f02c16926daa7507627df9342edf /Libraries/LibCore/DirIterator.cpp | |
parent | 3879d752190018fc06cb34251c22ad6273cab8a4 (diff) | |
download | serenity-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.cpp | 3 |
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(); } } |