dinotify

A tiny library to work with Linux's kernel inotify subsystem.

Members

Functions

iNotify
auto iNotify()

Structs

Event
struct Event

D-ified intofiy event, holds slice to temporary buffer with z-string.

INotify
struct INotify
Undocumented in source.
Watch
struct Watch

Type-safe watch descriptor to help discern it from normal file descriptors

Examples

import std.file, std.stdio : writeln;
auto monitor = iNotify();
monitor.add(tempDir, IN_CREATE | IN_DELETE);
ubyte[] data = [1, 2, 3, 4];
write(tempDir ~ "/killme", data);
auto events = monitor.read();
assert(events[0].mask & IN_CREATE);
assert(events[0].name == "killme");
remove(tempDir ~ "/killme");
events = monitor.read();
assert(events[0].mask & IN_DELETE);
// Note: doesn't track nested directories
mkdir(tempDir ~ "/some-dir");
write(tempDir ~ "/some-dir/victim", data);
events = monitor.read();
assert(events.length == 1);
assert(events[0].mask & IN_CREATE);
assert(events[0].name == "some-dir");
remove(tempDir ~ "/some-dir/victim");
rmdir(tempDir ~ "/some-dir/");

Meta