diff options
Diffstat (limited to 'src/3rdParty/efsw/WatcherFSEvents.hpp')
-rw-r--r--[-rwxr-xr-x] | src/3rdParty/efsw/WatcherFSEvents.hpp | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/src/3rdParty/efsw/WatcherFSEvents.hpp b/src/3rdParty/efsw/WatcherFSEvents.hpp index 4dbb231..f05b094 100755..100644 --- a/src/3rdParty/efsw/WatcherFSEvents.hpp +++ b/src/3rdParty/efsw/WatcherFSEvents.hpp | |||
@@ -9,51 +9,72 @@ | |||
9 | #include <CoreServices/CoreServices.h> | 9 | #include <CoreServices/CoreServices.h> |
10 | #include <efsw/FileInfo.hpp> | 10 | #include <efsw/FileInfo.hpp> |
11 | #include <efsw/WatcherGeneric.hpp> | 11 | #include <efsw/WatcherGeneric.hpp> |
12 | #include <set> | 12 | #include <unordered_set> |
13 | #include <vector> | 13 | #include <vector> |
14 | 14 | ||
15 | namespace efsw { | 15 | namespace efsw { |
16 | 16 | ||
17 | /* OSX < 10.7 has no file events */ | ||
18 | /* So i declare the events constants */ | ||
19 | enum FSEventEvents { | ||
20 | efswFSEventStreamCreateFlagUseCFTypes = 0x00000001, | ||
21 | efswFSEventStreamCreateFlagNoDefer = 0x00000002, | ||
22 | efswFSEventStreamCreateFlagFileEvents = 0x00000010, | ||
23 | efswFSEventStreamCreateFlagUseExtendedData = 0x00000040, | ||
24 | efswFSEventStreamEventFlagItemCreated = 0x00000100, | ||
25 | efswFSEventStreamEventFlagItemRemoved = 0x00000200, | ||
26 | efswFSEventStreamEventFlagItemInodeMetaMod = 0x00000400, | ||
27 | efswFSEventStreamEventFlagItemRenamed = 0x00000800, | ||
28 | efswFSEventStreamEventFlagItemModified = 0x00001000, | ||
29 | efswFSEventStreamEventFlagItemFinderInfoMod = 0x00002000, | ||
30 | efswFSEventStreamEventFlagItemChangeOwner = 0x00004000, | ||
31 | efswFSEventStreamEventFlagItemXattrMod = 0x00008000, | ||
32 | efswFSEventStreamEventFlagItemIsFile = 0x00010000, | ||
33 | efswFSEventStreamEventFlagItemIsDir = 0x00020000, | ||
34 | efswFSEventStreamEventFlagItemIsSymlink = 0x00040000, | ||
35 | efswFSEventsModified = efswFSEventStreamEventFlagItemFinderInfoMod | | ||
36 | efswFSEventStreamEventFlagItemModified | | ||
37 | efswFSEventStreamEventFlagItemInodeMetaMod | ||
38 | }; | ||
39 | |||
17 | class FileWatcherFSEvents; | 40 | class FileWatcherFSEvents; |
18 | 41 | ||
19 | class FSEvent { | 42 | class FSEvent { |
20 | public: | 43 | public: |
21 | FSEvent( std::string path, long flags, Uint64 id ) : Path( path ), Flags( flags ), Id( id ) {} | 44 | FSEvent( std::string path, long flags, Uint64 id, Uint64 inode = 0 ) : |
45 | Path( path ), Flags( flags ), Id( id ), inode( inode ) {} | ||
22 | 46 | ||
23 | std::string Path; | 47 | std::string Path; |
24 | long Flags; | 48 | long Flags{ 0 }; |
25 | Uint64 Id; | 49 | Uint64 Id{ 0 }; |
50 | Uint64 inode{ 0 }; | ||
26 | }; | 51 | }; |
27 | 52 | ||
28 | class WatcherFSEvents : public Watcher { | 53 | class WatcherFSEvents : public Watcher { |
29 | public: | 54 | public: |
30 | WatcherFSEvents(); | 55 | WatcherFSEvents(); |
31 | 56 | ||
32 | WatcherFSEvents( WatchID id, std::string directory, FileWatchListener* listener, bool recursive, | ||
33 | WatcherFSEvents* parent = NULL ); | ||
34 | |||
35 | ~WatcherFSEvents(); | 57 | ~WatcherFSEvents(); |
36 | 58 | ||
37 | void init(); | 59 | void init(); |
38 | 60 | ||
39 | void initAsync(); | ||
40 | |||
41 | void handleActions( std::vector<FSEvent>& events ); | 61 | void handleActions( std::vector<FSEvent>& events ); |
42 | 62 | ||
43 | void process(); | 63 | void process(); |
44 | 64 | ||
45 | Atomic<FileWatcherFSEvents*> FWatcher; | 65 | Atomic<FileWatcherFSEvents*> FWatcher; |
46 | FSEventStreamRef FSStream; | 66 | FSEventStreamRef FSStream; |
67 | Uint64 ModifiedFlags{ efswFSEventsModified }; | ||
68 | bool SanitizeEvents{ false }; | ||
47 | 69 | ||
48 | protected: | 70 | protected: |
49 | void handleAddModDel( const Uint32& flags, const std::string& path, std::string& dirPath, | 71 | void handleAddModDel( const Uint32& flags, const std::string& path, std::string& dirPath, |
50 | std::string& filePath ); | 72 | std::string& filePath, Uint64 inode ); |
51 | 73 | ||
52 | WatcherGeneric* WatcherGen; | 74 | WatcherGeneric* WatcherGen; |
53 | 75 | ||
54 | Atomic<bool> initializedAsync; | 76 | std::unordered_set<std::string> DirsChanged; |
55 | 77 | std::unordered_set<Uint64> FilesAdded; | |
56 | std::set<std::string> DirsChanged; | ||
57 | 78 | ||
58 | void sendFileAction( WatchID watchid, const std::string& dir, const std::string& filename, | 79 | void sendFileAction( WatchID watchid, const std::string& dir, const std::string& filename, |
59 | Action action, std::string oldFilename = "" ); | 80 | Action action, std::string oldFilename = "" ); |