1 (* unit testing inotify *)
6 if Array.length Sys.argv < 2 then (
7 eprintf "usage: %s <path>\n" Sys.argv.(0);
11 let fd = Inotify.init () in
12 ignore (Inotify.add_watch fd Sys.argv.(1) [ Inotify.S_Create ]);
14 let string_of_event ev =
15 let wd,mask,cookie,s = ev in
16 let mask = String.concat ":" (List.map Inotify.string_of_event mask) in
17 let s = match s with Some s -> s | None -> "\"\"" in
18 sprintf "wd [%u] mask[%s] cookie[%ld] %s" (Inotify.int_of_wd wd)
25 let _, _, _ = Unix.select [ fd ] [] [] (-1.) in
26 let evs = Inotify.read fd in
28 printf "[%d] %s\n%!" !nb (string_of_event ev)) evs;