CDirIterator.h 575 B

1234567891011121314151617181920212223242526272829
  1. #pragma once
  2. #include <AK/String.h>
  3. #include <dirent.h>
  4. class CDirIterator {
  5. public:
  6. enum Flags {
  7. NoFlags = 0x0,
  8. SkipDots = 0x1,
  9. };
  10. CDirIterator(const StringView& path, Flags = Flags::NoFlags);
  11. ~CDirIterator();
  12. bool has_error() const { return m_error != 0; }
  13. int error() const { return m_error; }
  14. const char* error_string() const { return strerror(m_error); }
  15. bool has_next();
  16. String next_path();
  17. private:
  18. DIR* m_dir = nullptr;
  19. int m_error = 0;
  20. String m_next;
  21. int m_flags;
  22. bool advance_next();
  23. };