49 lines
1.0 KiB
C++
49 lines
1.0 KiB
C++
#ifndef NOTIFY_H_
|
|
#define NOTIFY_H_
|
|
|
|
#include <iostream>
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
#include <utility>
|
|
|
|
struct notify_event
|
|
{
|
|
std::string file;
|
|
uint32_t mask;
|
|
};
|
|
|
|
class Notify
|
|
{
|
|
private:
|
|
// Stream where to log errors
|
|
std::ostream& m_log_stream;
|
|
|
|
// inotify FD
|
|
int m_notify_fd;
|
|
|
|
// Map of watch FDs
|
|
std::map<std::string, int> m_watch_fds;
|
|
|
|
std::vector<std::pair<int, notify_event>> get_watch_events() const;
|
|
|
|
public:
|
|
Notify(std::ostream& log_stream = std::cout);
|
|
~Notify();
|
|
|
|
void add_file(const std::string& filename, uint32_t mask);
|
|
void add_list(const std::vector<std::string>& files, uint32_t mask);
|
|
void add_list(const std::vector<std::pair<std::string, uint32_t>>& files);
|
|
void remove_file(const std::string& filename);
|
|
void remove_list(const std::vector<std::string>& files);
|
|
void clear();
|
|
size_t size() const;
|
|
|
|
std::vector<std::string> get_list() const;
|
|
void set_list(std::vector<std::pair<std::string, uint32_t>>& files);
|
|
|
|
std::vector<notify_event> get_events() const;
|
|
};
|
|
|
|
#endif // NOTIFY_H_
|