dinotify

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

Members

Functions

iNotify
auto iNotify()

Create new INotify struct

iNotifyTree
auto iNotifyTree(string path, uint mask)

Structs

Event
struct Event

D-ified inotify 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.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");

Meta