Create new INotify struct
D-ified inotify event, holds slice to temporary buffer with z-string.
Type-safe watch descriptor to help discern it from normal file descriptors
import std.process, std.stdio : writeln; auto monitor = iNotify(); system("mkdir tmp"); monitor.add("tmp".ptr, IN_CREATE | IN_DELETE); ubyte[] data = [1, 2, 3, 4]; system("touch tmp/killme"); auto events = monitor.read(); assert(events[0].mask == IN_CREATE); assert(events[0].name == "killme"); system("rm -rf tmp/killme"); events = monitor.read(); assert(events[0].mask == IN_DELETE); // Note: watched directory doesn't track events in sub-directories system("mkdir tmp/some-dir"); system("touch tmp/some-dir/victim"); events = monitor.read(); assert(events.length == 1); assert(events[0].mask == (IN_ISDIR | IN_CREATE)); assert(events[0].name == "some-dir"); system("rm -rf tmp");
A tiny library to work with Linux's kernel inotify subsystem.