CmWin32FolderMonitor.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #pragma once
  2. #include "CmPrerequisites.h"
  3. namespace CamelotFramework
  4. {
  5. enum class FolderChange
  6. {
  7. FileName = 0x0001,
  8. DirName = 0x0002,
  9. Attributes = 0x0004,
  10. Size = 0x0008,
  11. LastWrite = 0x0010,
  12. LastAccess = 0x0020,
  13. Creation = 0x0040,
  14. Security = 0x0080
  15. };
  16. class CM_EXPORT FolderMonitor
  17. {
  18. struct Pimpl;
  19. class FileNotifyInfo;
  20. struct FolderWatchInfo;
  21. public:
  22. FolderMonitor();
  23. ~FolderMonitor();
  24. void startMonitor(const WString& folderPath, bool subdirectories, FolderChange changeFilter);
  25. void stopMonitor(const WString& folderPath);
  26. void stopMonitorAll();
  27. /**
  28. * @brief Callbacks will only get fired after update is called().
  29. *
  30. * @note Internal method.
  31. */
  32. void update();
  33. boost::signal<void(const WString&)> onModified;
  34. boost::signal<void(const WString&)> onAdded;
  35. boost::signal<void(const WString&)> onRemoved;
  36. boost::signal<void(const WString&, const WString&)> onRenamed;
  37. private:
  38. Pimpl* mPimpl;
  39. void workerThreadMain();
  40. void handleNotifications(FileNotifyInfo& notifyInfo, FolderWatchInfo& watchInfo);
  41. };
  42. }