1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
import std.stdio, std.file, std.date, std.c.time;

void main(string[] args) {
    if(args.length <= 1) return;
    auto filename = args[1];
    
    d_time lastmod = mtime(filename);
    while(true) {
        d_time lastmod2 = mtime(filename);
        if(lastmod != lastmod2) {
            writeln("modified!");
            lastmod = lastmod2;
        }
        msleep(1000);
    }
}

d_time mtime(string file) {
    d_time ftc, fta, ftm;
    getTimes(file, ftc, fta, ftm);
    return ftm;
}