in lib/src/directory_watcher/windows.dart [124:154]
void _startParentWatcher() {
var absoluteDir = p.absolute(path);
var parent = p.dirname(absoluteDir);
// Check if [path] is already the root directory.
if (FileSystemEntity.identicalSync(parent, path)) return;
var parentStream = Directory(parent).watch(recursive: false);
_parentWatchSubscription = parentStream.listen((event) {
// Only look at events for 'directory'.
if (p.basename(event.path) != p.basename(absoluteDir)) return;
// Test if the directory is removed. FileSystemEntity.typeSync will
// return NOT_FOUND if it's unable to decide upon the type, including
// access denied issues, which may happen when the directory is deleted.
// FileSystemMoveEvent and FileSystemDeleteEvent events will always mean
// the directory is now gone.
if (event is FileSystemMoveEvent ||
event is FileSystemDeleteEvent ||
(FileSystemEntity.typeSync(path) == FileSystemEntityType.notFound)) {
for (var path in _files.paths) {
_emitEvent(ChangeType.REMOVE, path);
}
_files.clear();
close();
}
}, onError: (error) {
// Ignore errors, simply close the stream. The user listens on
// [directory], and while it can fail to listen on the parent, we may
// still be able to listen on the path requested.
_parentWatchSubscription?.cancel();
_parentWatchSubscription = null;
});
}