mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-15 12:15:36 +02:00
backward compatible for ldc v1.20.1
This commit is contained in:
parent
45ef630959
commit
991fe88512
|
@ -35,7 +35,7 @@ class MonitorException: ErrnoException {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shared class MonitorBackgroundWorker {
|
class MonitorBackgroundWorker {
|
||||||
// inotify file descriptor
|
// inotify file descriptor
|
||||||
int fd;
|
int fd;
|
||||||
Pipe p;
|
Pipe p;
|
||||||
|
@ -43,16 +43,16 @@ shared class MonitorBackgroundWorker {
|
||||||
|
|
||||||
this() {
|
this() {
|
||||||
isAlive = true;
|
isAlive = true;
|
||||||
p = cast(shared) pipe();
|
p = pipe();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialise() {
|
shared void initialise() {
|
||||||
fd = inotify_init();
|
fd = inotify_init();
|
||||||
if (fd < 0) throw new MonitorException("inotify_init failed");
|
if (fd < 0) throw new MonitorException("inotify_init failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add this path to be monitored
|
// Add this path to be monitored
|
||||||
private int addInotifyWatch(string pathname) {
|
shared int addInotifyWatch(string pathname) {
|
||||||
int wd = inotify_add_watch(fd, toStringz(pathname), mask);
|
int wd = inotify_add_watch(fd, toStringz(pathname), mask);
|
||||||
if (wd < 0) {
|
if (wd < 0) {
|
||||||
if (errno() == ENOSPC) {
|
if (errno() == ENOSPC) {
|
||||||
|
@ -83,11 +83,11 @@ shared class MonitorBackgroundWorker {
|
||||||
return wd;
|
return wd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int removeInotifyWatch(int wd) {
|
shared int removeInotifyWatch(int wd) {
|
||||||
return inotify_rm_watch(fd, wd);
|
return inotify_rm_watch(fd, wd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void watch(Tid callerTid) {
|
shared void watch(Tid callerTid) {
|
||||||
// On failure, send -1 to caller
|
// On failure, send -1 to caller
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
@ -124,13 +124,13 @@ shared class MonitorBackgroundWorker {
|
||||||
callerTid.send(0);
|
callerTid.send(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void interrupt() {
|
shared void interrupt() {
|
||||||
isAlive = false;
|
isAlive = false;
|
||||||
(cast()p).writeEnd.writeln("done");
|
(cast()p).writeEnd.writeln("done");
|
||||||
(cast()p).writeEnd.flush();
|
(cast()p).writeEnd.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void shutdown() {
|
shared void shutdown() {
|
||||||
isAlive = false;
|
isAlive = false;
|
||||||
if (fd > 0) {
|
if (fd > 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -202,7 +202,7 @@ final class Monitor {
|
||||||
|
|
||||||
assert(onDirCreated && onFileChanged && onDelete && onMove);
|
assert(onDirCreated && onFileChanged && onDelete && onMove);
|
||||||
if (!buffer) buffer = new void[4096];
|
if (!buffer) buffer = new void[4096];
|
||||||
worker = new shared(MonitorBackgroundWorker);
|
worker = cast(shared) new MonitorBackgroundWorker;
|
||||||
worker.initialise();
|
worker.initialise();
|
||||||
|
|
||||||
// from which point do we start watching for changes?
|
// from which point do we start watching for changes?
|
||||||
|
@ -546,5 +546,4 @@ final class Monitor {
|
||||||
addLogEntry("inotify events flushed", ["debug"]);
|
addLogEntry("inotify events flushed", ["debug"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue