in lib/src/directory_watcher/linux.dart [148:193]
void _onBatch(List<FileSystemEvent> batch) {
var files = <String>{};
var dirs = <String>{};
var changed = <String>{};
// inotify event batches are ordered by occurrence, so we treat them as a
// log of what happened to a file. We only emit events based on the
// difference between the state before the batch and the state after it, not
// the intermediate state.
for (var event in batch) {
// If the watched directory is deleted or moved, we'll get a deletion
// event for it. Ignore it; we handle closing [this] when the underlying
// stream is closed.
if (event.path == path) continue;
changed.add(event.path);
if (event is FileSystemMoveEvent) {
files.remove(event.path);
dirs.remove(event.path);
var destination = event.destination;
if (destination == null) continue;
changed.add(destination);
if (event.isDirectory) {
files.remove(destination);
dirs.add(destination);
} else {
files.add(destination);
dirs.remove(destination);
}
} else if (event is FileSystemDeleteEvent) {
files.remove(event.path);
dirs.remove(event.path);
} else if (event.isDirectory) {
files.remove(event.path);
dirs.add(event.path);
} else {
files.add(event.path);
dirs.remove(event.path);
}
}
_applyChanges(files, dirs, changed);
}