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