fs_watcher.h
1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef SCOT_FS_WATCHER_H
#define SCOT_FS_WATCHER_H
#include <scot/event_listener.h>
#include <scot/thread.h>
#include <scot/stream.h>
#include <scot/list_type_proto.h>
struct scot_fsw_info
{
int watch_d;
char * path;
uint32_t mask;
uint32_t got_events; /* also a mask, that shows, which events already
occured (will be 0 at init and after a callback was
called.) */
char * old_name; /* This is used within rename events. With inotify
a rename is build up from 2 inotify_events.
IN_MOVE_FROM and IN_MOVE_TO. The move from
event holds the old name. This old name is saved
here if an IN_MOVE_FORM occured. */
};
typedef struct scot_fsw_info scot_fsw_info;
GEN_LIST_TYPE_PROTO (scot_fsw_info);
struct scot_fs_watcher
{
struct scot_event_listener el;
fd_set rfds;
struct scot_stream notify_d;
list_scot_fsw_info_node_t * w_list;
THREAD_MUTEX_T mutex;
};
struct scot_fs_watcher * scot_fs_watcher_new (void);
void scot_fs_watcher_free (struct scot_fs_watcher *);
void scot_fs_watcher_add (struct scot_fs_watcher *, const char *, uint32_t);
void scot_fs_watcher_remove (struct scot_fs_watcher *, const char *, uint32_t);
int scot_fs_watcher_get_mask (struct scot_fs_watcher *, int);
void scot_fs_watcher_main_loop (struct scot_fs_watcher *);
#endif /* SCOT_FS_WATCHER_H */