ezEngine  Milestone 7
DirectoryWatcher.h
1 #pragma once
2 
3 #include <Foundation/Basics.h>
4 #include <Foundation/Strings/String.h>
6 #include <Foundation/Types/Delegate.h>
7 
9 
12 class EZ_FOUNDATION_DLL ezDirectoryWatcher
13 {
14 public:
16  struct Watch
17  {
18  typedef ezUInt8 StorageType;
19 
21  enum Enum
22  {
23  Reads = EZ_BIT(0),
24  Writes = EZ_BIT(1),
25  Creates = EZ_BIT(2),
26  Renames = EZ_BIT(3),
27  Subdirectories = EZ_BIT(4)
28  };
29 
30  struct Bits
31  {
32  StorageType Reads : 1;
33  StorageType Writes : 1;
34  StorageType Creates : 1;
35  StorageType Renames : 1;
36  StorageType Subdirectories : 1;
37  };
38  };
39 
41  enum class Action
42  {
43  Added,
44  Removed,
45  Modified,
46  RenamedOldName,
47  RenamedNewName,
48  };
49 
52 
57  ezResult OpenDirectory(const ezString& path, ezBitflags<Watch> whatToWatch);
58 
61  void CloseDirectory();
62 
68  void EnumerateChanges(ezDelegate<void(const char* filename, Action action)> func);
69 
70 private:
71  bool m_bDirectoryOpen;
72  ezDirectoryWatcherImpl* m_pImpl;
73 };