summaryrefslogtreecommitdiff
path: root/src/fs_event/fs_event.h
blob: b25270eb54a96ead45d38ff3221f0b6c92c621b1 (plain)
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
#pragma once

#include <al/str.h>

#ifdef NAUNET_ON_WINDOWS
struct inotify_event {};
#define NNWT_FS_CLOSE_WRITE 0
#else
#include <sys/inotify.h>
#define NNWT_FS_CLOSE_WRITE IN_CLOSE_WRITE
#define NNWT_FS_CREATE IN_CREATE
#endif

#include "../loop.h"

struct nn_fs_event {
    s32 fd;
    u32 mask;
    char *path;
    s32 wd;
    ev_io event;
    struct nn_event_loop *loop;
    void (*callback)(void *, struct inotify_event *);
    void *userdata;
};

void nn_fs_event_init(struct nn_fs_event *fs, str *path, u32 mask,
    void (*callback)(void *, struct inotify_event *), void *userdata);
bool nn_fs_event_start(struct nn_fs_event *fs, struct nn_event_loop *loop);
void nn_fs_event_stop(struct nn_fs_event *fs);
void nn_fs_event_free(struct nn_fs_event *fs);