aboutsummaryrefslogtreecommitdiff
path: root/src/3rdParty/efsw/WatcherFSEvents.hpp
diff options
context:
space:
mode:
authorLi Jin <dragon-fly@qq.com>2022-11-15 17:23:46 +0800
committerLi Jin <dragon-fly@qq.com>2022-11-15 17:52:09 +0800
commit94f8330613877b3582d32bd11abd83a97b4399ad (patch)
tree5359de314be1ebde17f8d1e48632a97d18f9e50f /src/3rdParty/efsw/WatcherFSEvents.hpp
parent60f8f00a022ac08701792b2897b72d8c99b50f52 (diff)
downloadyuescript-94f8330613877b3582d32bd11abd83a97b4399ad.tar.gz
yuescript-94f8330613877b3582d32bd11abd83a97b4399ad.tar.bz2
yuescript-94f8330613877b3582d32bd11abd83a97b4399ad.zip
adding -w option to Yuescript tool.
Diffstat (limited to 'src/3rdParty/efsw/WatcherFSEvents.hpp')
-rwxr-xr-xsrc/3rdParty/efsw/WatcherFSEvents.hpp66
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
15namespace efsw {
16
17class FileWatcherFSEvents;
18
19class 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
28class 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