mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-17 21:10:39 +02:00
6e8491abee
This is necessary in C, but unusual in C++.
31 lines
608 B
C++
31 lines
608 B
C++
#ifndef __MONITOR_H__
|
|
#define __MONITOR_H__
|
|
#ifdef ENABLE_INOTIFY
|
|
|
|
#include <pthread.h>
|
|
#include <string>
|
|
#include <sys/inotify.h>
|
|
|
|
class Monitor {
|
|
public:
|
|
Monitor(std::string path, unsigned int flags = IN_MOVE |
|
|
IN_CLOSE_WRITE | IN_DELETE | IN_CREATE |
|
|
IN_DELETE_SELF | IN_MOVE_SELF);
|
|
virtual ~Monitor();
|
|
|
|
int run();
|
|
const std::string getPath() { return path; }
|
|
|
|
private:
|
|
std::string path;
|
|
pthread_t thd;
|
|
|
|
protected:
|
|
unsigned int mask;
|
|
virtual bool event_accepted(struct inotify_event &event);
|
|
virtual void inject_event(bool is_add, const char *path);
|
|
};
|
|
|
|
#endif
|
|
#endif /* __MONITOR_H__ */
|