]> git.tdb.fi Git - libs/core.git/blob - source/fs/unix/filemonitor_platform.h
Add a class for monitoring changes in files
[libs/core.git] / source / fs / unix / filemonitor_platform.h
1 #ifndef MSP_FS_FILEMONITOR_PLATFORM_H_
2 #define MSP_FS_FILEMONITOR_PLATFORM_H_
3
4 namespace Msp {
5 namespace FS {
6
7 class INotify: public IO::EventObject
8 {
9 private:
10         IO::Handle fd;
11
12 public:
13         INotify();
14         ~INotify();
15
16         int add_watch(const FS::Path &, int);
17         void remove_watch(int);
18
19         virtual void set_block(bool) { }
20         virtual void set_inherit(bool) { }
21
22 protected:
23         virtual unsigned do_write(const char *, unsigned);
24         virtual unsigned do_read(char *, unsigned);
25
26 public:
27         virtual const IO::Handle &get_handle(IO::Mode) { return fd; }
28         virtual const IO::Handle &get_event_handle() { return fd; }
29 };
30
31
32 struct FileMonitor::Private
33 {
34         FileMonitor &monitor;
35         INotify inotify;
36
37         Private(FileMonitor &);
38
39         void events_available();
40 };
41
42 } // namespace FS
43 } // namespace Msp
44
45 #endif