iNotifyTree

Undocumented in source. Be warned that the author may not have intended to support it.
  1. auto iNotifyTree(string path, uint mask)
  2. auto iNotifyTree(string[] roots, uint mask)
    iNotifyTree
    (
    string[] roots
    ,
    uint mask
    )

Examples

import std.process;
import core.thread;

executeShell("rm -rf tmp");
executeShell("mkdir -p tmp/dir1/dir11");
executeShell("mkdir -p tmp/dir1/dir12");
auto ntree = iNotifyTree("tmp/dir1", IN_CREATE | IN_DELETE);
executeShell("touch tmp/dir1/dir11/a.tmp");
executeShell("touch tmp/dir1/dir12/b.tmp");
executeShell("rm -rf tmp/dir1/dir12");
auto evs = ntree.read();
assert(evs.length == 4);
// a & b files created
assert(evs[0].mask == IN_CREATE && evs[0].path == "tmp/dir1/dir11/a.tmp");
assert(evs[1].mask == IN_CREATE && evs[1].path == "tmp/dir1/dir12/b.tmp");
// b deleted as part of sub-tree
assert(evs[2].mask == IN_DELETE && evs[2].path == "tmp/dir1/dir12/b.tmp");
assert(evs[3].mask == (IN_DELETE | IN_ISDIR) && evs[3].path == "tmp/dir1/dir12");
evs = ntree.read(10.msecs);
assert(evs.length == 0);
auto t = new Thread((){
    Thread.sleep(1000.msecs);
    executeShell("touch tmp/dir1/dir11/c.tmp");
}).start();
evs = ntree.read(10.msecs);
t.join();
assert(evs.length == 0);
evs = ntree.read(10.msecs);
assert(evs.length == 1);

Meta