1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:08:10 +00:00

Libraries: Create top level directory for libraries.

Things were getting a little crowded in the project root, so this patch
moves the Lib*/ directories into Libraries/.
This commit is contained in:
Andreas Kling 2019-07-04 16:16:50 +02:00
parent 63814ffebf
commit 04b9dc2d30
328 changed files with 36 additions and 36 deletions

View file

@ -0,0 +1,67 @@
#include "CDirIterator.h"
#include <cerrno>
CDirIterator::CDirIterator(const StringView& path, Flags flags)
: m_flags(flags)
{
m_dir = opendir(path.characters());
if (m_dir == nullptr) {
m_error = errno;
}
}
CDirIterator::~CDirIterator()
{
if (m_dir != nullptr) {
closedir(m_dir);
m_dir = nullptr;
}
}
bool CDirIterator::advance_next()
{
if (m_dir == nullptr)
return false;
bool keep_advancing = true;
while (keep_advancing) {
errno = 0;
auto* de = readdir(m_dir);
if (de) {
m_next = de->d_name;
} else {
m_error = errno;
m_next = String();
}
if (m_next.is_null()) {
keep_advancing = false;
} else if (m_flags & Flags::SkipDots) {
if (m_next.length() < 1 || m_next[0] != '.') {
keep_advancing = false;
}
} else {
keep_advancing = false;
}
}
return m_next.length() > 0;
}
bool CDirIterator::has_next()
{
if (!m_next.is_null())
return true;
return advance_next();
}
String CDirIterator::next_path()
{
if (m_next.is_null())
advance_next();
auto tmp = m_next;
m_next = String();
return tmp;
}