mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:07:44 +00:00
LibCore: Add SkipParentAndBaseDir flag in DirIterator
Sometimes we may want to iterate over dotfiles but not include the parent or base directory
This commit is contained in:
parent
3879d75219
commit
6764b77788
2 changed files with 4 additions and 0 deletions
|
@ -67,6 +67,9 @@ bool DirIterator::advance_next()
|
||||||
if (m_flags & Flags::SkipDots && m_next.starts_with('.'))
|
if (m_flags & Flags::SkipDots && m_next.starts_with('.'))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (m_flags & Flags::SkipParentAndBaseDir && (m_next == "." || m_next == ".."))
|
||||||
|
continue;
|
||||||
|
|
||||||
return !m_next.is_empty();
|
return !m_next.is_empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
enum Flags {
|
enum Flags {
|
||||||
NoFlags = 0x0,
|
NoFlags = 0x0,
|
||||||
SkipDots = 0x1,
|
SkipDots = 0x1,
|
||||||
|
SkipParentAndBaseDir = 0x2,
|
||||||
};
|
};
|
||||||
|
|
||||||
DirIterator(const StringView& path, Flags = Flags::NoFlags);
|
DirIterator(const StringView& path, Flags = Flags::NoFlags);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue