1
0

readdir.h 949 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _READDIR_H
  2. #define _READDIR_H
  3. #include <bfc/common.h>
  4. #include <bfc/string/StringW.h>
  5. /* intended use:
  6. ReadDir dir(path);
  7. while (dir.next()) {
  8. const char *fn = dir.getFilename();
  9. }
  10. */
  11. class ReadDir
  12. {
  13. public:
  14. ReadDir(const wchar_t *path, const wchar_t *match=NULL, bool skipdots=true);
  15. ~ReadDir();
  16. int next(); // done when returns 0
  17. const wchar_t *getFilename();
  18. int isDir(); // if current file is a dir
  19. int isReadonly(); // if current file is readonly
  20. int isDotDir(); // if given dir iteself is being enumerated (usually ".")
  21. int isDotDotDir(); // if parent dir of cur dir is showing (usually "..")
  22. const wchar_t *getPath() { return path; }
  23. private:
  24. StringW path, match;
  25. int skipdots, first;
  26. //PORT
  27. #ifdef WIN32
  28. HANDLE files;
  29. WIN32_FIND_DATAW data; // (shrug) so we have two? so what?
  30. //StringW filename;
  31. #endif
  32. #ifdef LINUX
  33. DIR *d;
  34. struct dirent *de;
  35. struct stat st;
  36. #endif
  37. };
  38. #endif