aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/efsw/FileWatcherWin32.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdParty/efsw/FileWatcherWin32.hpp')
-rwxr-xr-xsrc/3rdParty/efsw/FileWatcherWin32.hpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/3rdParty/efsw/FileWatcherWin32.hpp b/src/3rdParty/efsw/FileWatcherWin32.hpp
new file mode 100755
index 0000000..94439cf
--- /dev/null
+++ b/src/3rdParty/efsw/FileWatcherWin32.hpp
@@ -0,0 +1,70 @@
1#ifndef EFSW_FILEWATCHERWIN32_HPP
2#define EFSW_FILEWATCHERWIN32_HPP
3
4#include <efsw/base.hpp>
5
6#if EFSW_PLATFORM == EFSW_PLATFORM_WIN32
7
8#include <efsw/WatcherWin32.hpp>
9#include <map>
10#include <set>
11#include <vector>
12
13namespace efsw {
14
15/// Implementation for Win32 based on ReadDirectoryChangesW.
16/// @class FileWatcherWin32
17class FileWatcherWin32 : public FileWatcherImpl {
18 public:
19 /// type for a map from WatchID to WatcherWin32 pointer
20 typedef std::set<WatcherStructWin32*> Watches;
21
22 FileWatcherWin32( FileWatcher* parent );
23
24 virtual ~FileWatcherWin32();
25
26 /// Add a directory watch
27 /// On error returns WatchID with Error type.
28 WatchID addWatch( const std::string& directory, FileWatchListener* watcher, bool recursive );
29
30 /// Remove a directory watch. This is a brute force lazy search O(nlogn).
31 void removeWatch( const std::string& directory );
32
33 /// Remove a directory watch. This is a map lookup O(logn).
34 void removeWatch( WatchID watchid );
35
36 /// Updates the watcher. Must be called often.
37 void watch();
38
39 /// Handles the action
40 void handleAction( Watcher* watch, const std::string& filename, unsigned long action,
41 std::string oldFilename = "" );
42
43 /// @return Returns a list of the directories that are being watched
44 std::list<std::string> directories();
45
46 protected:
47 HANDLE mIOCP;
48 Watches mWatches;
49
50 /// The last watchid
51 WatchID mLastWatchID;
52 Thread* mThread;
53 Mutex mWatchesLock;
54
55 bool pathInWatches( const std::string& path );
56
57 /// Remove all directory watches.
58 void removeAllWatches();
59
60 void removeWatch( WatcherStructWin32* watch );
61
62 private:
63 void run();
64};
65
66} // namespace efsw
67
68#endif
69
70#endif