-
Notifications
You must be signed in to change notification settings - Fork 21
/
test.c
44 lines (39 loc) · 1.07 KB
/
test.c
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
#include <stdio.h>
#define DMON_IMPL
#include "dmon.h"
#if DMON_OS_LINUX
#include "dmon_extra.h"
#endif
static void watch_callback(dmon_watch_id watch_id, dmon_action action, const char* rootdir,
const char* filepath, const char* oldfilepath, void* user)
{
(void)(user);
(void)(watch_id);
switch (action) {
case DMON_ACTION_CREATE:
printf("CREATE: [%s]%s\n", rootdir, filepath);
break;
case DMON_ACTION_DELETE:
printf("DELETE: [%s]%s\n", rootdir, filepath);
break;
case DMON_ACTION_MODIFY:
printf("MODIFY: [%s]%s\n", rootdir, filepath);
break;
case DMON_ACTION_MOVE:
printf("MOVE: [%s]%s -> [%s]%s\n", rootdir, oldfilepath, rootdir, filepath);
break;
}
}
int main(int argc, char* argv[])
{
if (argc > 1) {
dmon_init();
puts("waiting for changes ..");
dmon_watch(argv[1], watch_callback, DMON_WATCHFLAGS_RECURSIVE, NULL);
getchar();
dmon_deinit();
} else {
puts("usage: test dirname");
}
return 0;
}