Something like this:
module file_watcher;
import std.concurrency;
import std.file;
import std.signals;
import std.datetime;
void fileWatcher(Tid tid, string filename, int loopSleep) {
auto modified0 = timeLastModified(filename);
while (true) {
modified = timeLastModified(filename);
if (modified > modified0) {
modified0 = modified;
//if (onFileChange !is null)
// onFileChange(receiver);
}
sleep(dur!"msecs"(loopSleep));
}
}
But I'm not sure how to send the onFiledChange event.
How do I create a fileWatcher with an onFileChange event using spawn?
Enjoys Math via Digitalmars-d-learn Fri, 25 Aug 2017 14:31:13 -0700
- How do I create a fileWatcher with ... Enjoys Math via Digitalmars-d-learn
- Re: How do I create a fileWatc... Jacob Carlborg via Digitalmars-d-learn
- Re: How do I create a file... Nemanja Boric via Digitalmars-d-learn
- Re: How do I create a ... Jacob Carlborg via Digitalmars-d-learn
- Re: How do I creat... bauss via Digitalmars-d-learn
- Re: How do I create a file... Enjoys Math via Digitalmars-d-learn
- Re: How do I create a fileWatc... shuji via Digitalmars-d-learn
