blob: c0b55796050a874ac5c24744890b29c060695d0d (
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
|
#include <stdio.h>
#include <string.h>
#include <inotifytools/inotifytools.h>
#include <inotifytools/inotify.h>
/*
* libinotifytools example program.
* Compile with gcc -linotifytools example.c
*/
int main() {
// initialize and watch the entire directory tree from the current working
// directory downwards for all events
if ( !inotifytools_initialize()
|| !inotifytools_watch_recursively( ".", IN_ALL_EVENTS ) ) {
fprintf(stderr, "%s\n", strerror( inotifytools_error() ) );
return -1;
}
// set time format to 24 hour time, HH:MM:SS
inotifytools_set_printf_timefmt( "%T" );
// Output all events as "<timestamp> <path> <events>"
struct inotify_event * event = inotifytools_next_event( -1 );
while ( event ) {
inotifytools_printf( event, "%T %w%f %e\n" );
event = inotifytools_next_event( -1 );
}
}
|