1
0

FolderScanner.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * FolderScanner.h
  3. * ---------------
  4. * Purpose: Class for finding files in folders.
  5. * Notes : (currently none)
  6. * Authors: OpenMPT Devs
  7. * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
  8. */
  9. #pragma once
  10. #include "openmpt/all/BuildSettings.hpp"
  11. #include "../common/mptPathString.h"
  12. OPENMPT_NAMESPACE_BEGIN
  13. class FolderScanner
  14. {
  15. public:
  16. enum ScanType
  17. {
  18. kOnlyFiles = 0x01,
  19. kOnlyDirectories = 0x02,
  20. kFilesAndDirectories = kOnlyFiles | kOnlyDirectories,
  21. kFindInSubDirectories = 0x04,
  22. };
  23. protected:
  24. std::vector<mpt::PathString> m_paths;
  25. mpt::PathString m_currentPath;
  26. mpt::PathString m_filter;
  27. HANDLE m_hFind;
  28. WIN32_FIND_DATA m_wfd;
  29. FlagSet<ScanType> m_type;
  30. public:
  31. FolderScanner(const mpt::PathString &path, FlagSet<ScanType> type, mpt::PathString filter = MPT_PATHSTRING("*.*"));
  32. ~FolderScanner();
  33. // Return one file or directory at a time in parameter file. Returns true if a file was found (file parameter is valid), false if no more files can be found (file parameter is not touched).
  34. bool Next(mpt::PathString &file);
  35. };
  36. MPT_DECLARE_ENUM(FolderScanner::ScanType)
  37. OPENMPT_NAMESPACE_END