1
0

recursedir.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef _RECURSEDIR_H
  2. #define _RECURSEDIR_H
  3. #include <bfc/wasabi_std.h>
  4. #include <bfc/ptrlist.h>
  5. #include <bfc/common.h>
  6. #include <bfc/file/readdir.h>
  7. class ReadDir;
  8. /**
  9. Read the contents of a directory, recursively.
  10. Also possible to use search match patterns.
  11. @short Recursive directory reading.
  12. @author Nullsoft
  13. @ver 1.0
  14. @see ReadDir
  15. */
  16. class RecurseDir {
  17. public:
  18. /**
  19. Sets the directory to read and the match pattern.
  20. If no match pattern is set, it will match against
  21. all files.
  22. @param path The path of the directory to read.
  23. @param match The match pattern to use.
  24. */
  25. RecurseDir(const wchar_t *path, const wchar_t *match=NULL);
  26. /**
  27. Deletes the directory stack.
  28. */
  29. ~RecurseDir();
  30. /**
  31. Advance to the next file.
  32. @ret 0, No more files to read; > 0, Files left to read.
  33. */
  34. int next();
  35. /**
  36. Restart from the top of the directory tree.
  37. @ret 0
  38. */
  39. int restart();
  40. /**
  41. Get the current directory path.
  42. @ret The path.
  43. */
  44. const wchar_t *getPath();
  45. /**
  46. Get the filename for the current file.
  47. @ret The filename.
  48. */
  49. const wchar_t *getFilename();
  50. const wchar_t *getOriginalPath();
  51. private:
  52. StringW path, match;
  53. ReadDir *curdir;
  54. PtrList<ReadDir> dirstack;
  55. };
  56. #endif