diff options
Diffstat (limited to 'src/3rdParty/efsw/WatcherFSEvents.hpp')
-rwxr-xr-x | src/3rdParty/efsw/WatcherFSEvents.hpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/3rdParty/efsw/WatcherFSEvents.hpp b/src/3rdParty/efsw/WatcherFSEvents.hpp new file mode 100755 index 0000000..4dbb231 --- /dev/null +++ b/src/3rdParty/efsw/WatcherFSEvents.hpp | |||
@@ -0,0 +1,66 @@ | |||
1 | #ifndef EFSW_WATCHERINOTIFY_HPP | ||
2 | #define EFSW_WATCHERINOTIFY_HPP | ||
3 | |||
4 | #include <efsw/FileWatcherImpl.hpp> | ||
5 | |||
6 | #if EFSW_PLATFORM == EFSW_PLATFORM_FSEVENTS | ||
7 | |||
8 | #include <CoreFoundation/CoreFoundation.h> | ||
9 | #include <CoreServices/CoreServices.h> | ||
10 | #include <efsw/FileInfo.hpp> | ||
11 | #include <efsw/WatcherGeneric.hpp> | ||
12 | #include <set> | ||
13 | #include <vector> | ||
14 | |||
15 | namespace efsw { | ||
16 | |||
17 | class FileWatcherFSEvents; | ||
18 | |||
19 | class FSEvent { | ||
20 | public: | ||
21 | FSEvent( std::string path, long flags, Uint64 id ) : Path( path ), Flags( flags ), Id( id ) {} | ||
22 | |||
23 | std::string Path; | ||
24 | long Flags; | ||
25 | Uint64 Id; | ||
26 | }; | ||
27 | |||
28 | class WatcherFSEvents : public Watcher { | ||
29 | public: | ||
30 | WatcherFSEvents(); | ||
31 | |||
32 | WatcherFSEvents( WatchID id, std::string directory, FileWatchListener* listener, bool recursive, | ||
33 | WatcherFSEvents* parent = NULL ); | ||
34 | |||
35 | ~WatcherFSEvents(); | ||
36 | |||
37 | void init(); | ||
38 | |||
39 | void initAsync(); | ||
40 | |||
41 | void handleActions( std::vector<FSEvent>& events ); | ||
42 | |||
43 | void process(); | ||
44 | |||
45 | Atomic<FileWatcherFSEvents*> FWatcher; | ||
46 | FSEventStreamRef FSStream; | ||
47 | |||
48 | protected: | ||
49 | void handleAddModDel( const Uint32& flags, const std::string& path, std::string& dirPath, | ||
50 | std::string& filePath ); | ||
51 | |||
52 | WatcherGeneric* WatcherGen; | ||
53 | |||
54 | Atomic<bool> initializedAsync; | ||
55 | |||
56 | std::set<std::string> DirsChanged; | ||
57 | |||
58 | void sendFileAction( WatchID watchid, const std::string& dir, const std::string& filename, | ||
59 | Action action, std::string oldFilename = "" ); | ||
60 | }; | ||
61 | |||
62 | } // namespace efsw | ||
63 | |||
64 | #endif | ||
65 | |||
66 | #endif | ||