2019-05-27 07:26:54 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-09-06 13:34:26 +00:00
|
|
|
#include <AK/String.h>
|
2019-05-28 09:53:16 +00:00
|
|
|
#include <dirent.h>
|
2019-05-27 07:26:54 +00:00
|
|
|
|
|
|
|
class CDirIterator {
|
|
|
|
public:
|
2019-06-07 15:13:23 +00:00
|
|
|
enum Flags {
|
2019-05-27 07:26:54 +00:00
|
|
|
NoFlags = 0x0,
|
|
|
|
SkipDots = 0x1,
|
|
|
|
};
|
|
|
|
|
2019-06-02 10:26:28 +00:00
|
|
|
CDirIterator(const StringView& path, Flags = Flags::NoFlags);
|
2019-05-27 07:26:54 +00:00
|
|
|
~CDirIterator();
|
|
|
|
|
|
|
|
bool has_error() const { return m_error != 0; }
|
|
|
|
int error() const { return m_error; }
|
|
|
|
const char* error_string() const { return strerror(m_error); }
|
|
|
|
bool has_next();
|
|
|
|
String next_path();
|
|
|
|
|
|
|
|
private:
|
|
|
|
DIR* m_dir = nullptr;
|
|
|
|
int m_error = 0;
|
|
|
|
String m_next;
|
|
|
|
int m_flags;
|
|
|
|
|
|
|
|
bool advance_next();
|
|
|
|
};
|