main
Last change
on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago |
Pred finalna verzija
|
-
Property mode
set to
100644
|
File size:
946 bytes
|
Line | |
---|
1 | #ifndef INOTIFY_H
|
---|
2 | #define INOTIFY_H
|
---|
3 |
|
---|
4 | #include <unordered_map>
|
---|
5 | #include <sys/inotify.h>
|
---|
6 | #include "../shared/BruteForceBackend.hh"
|
---|
7 | #include "../DirTree.hh"
|
---|
8 | #include "../Signal.hh"
|
---|
9 |
|
---|
10 | struct InotifySubscription {
|
---|
11 | std::shared_ptr<DirTree> tree;
|
---|
12 | std::string path;
|
---|
13 | WatcherRef watcher;
|
---|
14 | };
|
---|
15 |
|
---|
16 | class InotifyBackend : public BruteForceBackend {
|
---|
17 | public:
|
---|
18 | void start() override;
|
---|
19 | ~InotifyBackend();
|
---|
20 | void subscribe(WatcherRef watcher) override;
|
---|
21 | void unsubscribe(WatcherRef watcher) override;
|
---|
22 | private:
|
---|
23 | int mPipe[2];
|
---|
24 | int mInotify;
|
---|
25 | std::unordered_multimap<int, std::shared_ptr<InotifySubscription>> mSubscriptions;
|
---|
26 | Signal mEndedSignal;
|
---|
27 |
|
---|
28 | bool watchDir(WatcherRef watcher, std::string path, std::shared_ptr<DirTree> tree);
|
---|
29 | void handleEvents();
|
---|
30 | void handleEvent(struct inotify_event *event, std::unordered_set<WatcherRef> &watchers);
|
---|
31 | bool handleSubscription(struct inotify_event *event, std::shared_ptr<InotifySubscription> sub);
|
---|
32 | };
|
---|
33 |
|
---|
34 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.