blob: d5bb97cc1259520f6cd3e4fcbf7214625e180883 (
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
32
33
34
35
36
37
38
39
40
41
|
#include <nnwt/common.h>
#include <nnwt/event_loop.h>
#include <nnwt/fs_event.h>
#include <nnwt/file.h>
static str TEST_FILE_PATH = al_str_c("./test.txt");
static struct nn_event_loop loop;
static struct nn_fs_event fs;
static void fs_event_callback(void *userdata, struct inotify_event *event)
{
(void)userdata;
(void)event;
al_printf("WRITE CLOSE\n");
nn_fs_event_stop(&fs);
}
s32 main(void)
{
if (!nn_common_init(NULL)) return EXIT_FAILURE;
nn_event_loop_init(&loop);
if (!nn_file_exists(&TEST_FILE_PATH)) {
nn_file_create(&TEST_FILE_PATH);
}
nn_fs_event_init(&fs, &TEST_FILE_PATH, NNWT_FS_CLOSE_WRITE, fs_event_callback, NULL);
if (!nn_fs_event_start(&fs, &loop)) {
return EXIT_FAILURE;
}
al_printf("Do something like: \"echo 'yo' > test.txt\"\n");
nn_event_loop_run(&loop);
nn_common_close();
return EXIT_SUCCESS;
}
|