forked from e-dant/watcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatcher-c.h
More file actions
72 lines (63 loc) · 1.9 KB
/
watcher-c.h
File metadata and controls
72 lines (63 loc) · 1.9 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Represents "what happened" to a path. */
static const int8_t WTR_WATCHER_EFFECT_RENAME = 0;
static const int8_t WTR_WATCHER_EFFECT_MODIFY = 1;
static const int8_t WTR_WATCHER_EFFECT_CREATE = 2;
static const int8_t WTR_WATCHER_EFFECT_DESTROY = 3;
static const int8_t WTR_WATCHER_EFFECT_OWNER = 4;
static const int8_t WTR_WATCHER_EFFECT_OTHER = 5;
/* Represents "what kind" of path it is. */
static const int8_t WTR_WATCHER_PATH_DIR = 0;
static const int8_t WTR_WATCHER_PATH_FILE = 1;
static const int8_t WTR_WATCHER_PATH_HARD_LINK = 2;
static const int8_t WTR_WATCHER_PATH_SYM_LINK = 3;
static const int8_t WTR_WATCHER_PATH_WATCHER = 4;
static const int8_t WTR_WATCHER_PATH_OTHER = 5;
/* The `event` object is used to carry information about
filesystem events to the user through the (user-supplied)
callback given to `watch`.
The `event` object will contain the:
- `path_name`: The path to the event.
- `path_type`: One of:
- dir
- file
- hard_link
- sym_link
- watcher
- other
- `effect_type`: One of:
- rename
- modify
- create
- destroy
- owner
- other
- `effect_time`:
The time of the event in nanoseconds since epoch.
*/
struct wtr_watcher_event {
int64_t effect_time;
char const* path_name;
char const* associated_path_name;
int8_t effect_type;
int8_t path_type;
};
/* Ensure the user's callback can receive
events and will return nothing. */
typedef void (* wtr_watcher_callback)(struct wtr_watcher_event event, void* context);
void* wtr_watcher_open(
char const* const path,
wtr_watcher_callback callback,
void* context,
char const* const* ignored_paths,
size_t ignored_paths_len);
bool wtr_watcher_close(void* watcher);
#ifdef __cplusplus
}
#endif