Gag directory modified events in win32.
This commit is contained in:
parent
99088e1202
commit
0ec498207d
|
@ -78,7 +78,8 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers {
|
||||||
void onIOCompleted(DWORD dwError, DWORD cbTransferred, OVERLAPPED* overlapped)
|
void onIOCompleted(DWORD dwError, DWORD cbTransferred, OVERLAPPED* overlapped)
|
||||||
{
|
{
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.path : dirName, baseName;
|
import std.file : isDir;
|
||||||
|
import std.path : dirName, baseName, buildPath;
|
||||||
|
|
||||||
if (dwError != 0) {
|
if (dwError != 0) {
|
||||||
// FIXME: this must be propagated to the caller
|
// FIXME: this must be propagated to the caller
|
||||||
|
@ -106,6 +107,8 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers {
|
||||||
do {
|
do {
|
||||||
assert(result.length >= FILE_NOTIFY_INFORMATION._FileName.offsetof);
|
assert(result.length >= FILE_NOTIFY_INFORMATION._FileName.offsetof);
|
||||||
auto fni = () @trusted { return cast(FILE_NOTIFY_INFORMATION*)result.ptr; } ();
|
auto fni = () @trusted { return cast(FILE_NOTIFY_INFORMATION*)result.ptr; } ();
|
||||||
|
result = result[fni.NextEntryOffset .. $];
|
||||||
|
|
||||||
FileChange ch;
|
FileChange ch;
|
||||||
switch (fni.Action) {
|
switch (fni.Action) {
|
||||||
default: ch.kind = FileChangeKind.modified; break;
|
default: ch.kind = FileChangeKind.modified; break;
|
||||||
|
@ -115,13 +118,17 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers {
|
||||||
case 0x4: ch.kind = FileChangeKind.removed; break;
|
case 0x4: ch.kind = FileChangeKind.removed; break;
|
||||||
case 0x5: ch.kind = FileChangeKind.added; break;
|
case 0x5: ch.kind = FileChangeKind.added; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ch.baseDirectory = slot.directory;
|
ch.baseDirectory = slot.directory;
|
||||||
auto path = () @trusted { scope (failure) assert(false); return to!string(fni.FileName[0 .. fni.FileNameLength/2]); } ();
|
auto path = () @trusted { scope (failure) assert(false); return to!string(fni.FileName[0 .. fni.FileNameLength/2]); } ();
|
||||||
|
auto fullpath = buildPath(slot.directory, path);
|
||||||
ch.directory = dirName(path);
|
ch.directory = dirName(path);
|
||||||
ch.name = baseName(path);
|
ch.name = baseName(path);
|
||||||
|
try ch.isDirectory = isDir(fullpath);
|
||||||
|
catch (Exception e) {} // FIXME: can happen if the base path is relative and the CWD has changed
|
||||||
|
if (ch.kind != FileChangeKind.modified || !ch.isDirectory)
|
||||||
slot.callback(id, ch);
|
slot.callback(id, ch);
|
||||||
if (fni.NextEntryOffset == 0) break;
|
if (fni.NextEntryOffset == 0) break;
|
||||||
result = result[fni.NextEntryOffset .. $];
|
|
||||||
} while (result.length > 0);
|
} while (result.length > 0);
|
||||||
|
|
||||||
triggerRead(handle, *slot);
|
triggerRead(handle, *slot);
|
||||||
|
|
Loading…
Reference in a new issue