| Index: runtime/bin/file_system_watcher_macos.cc
|
| diff --git a/runtime/bin/file_system_watcher_macos.cc b/runtime/bin/file_system_watcher_macos.cc
|
| index de0be2eb9c552fa32aab3fbf8abe894895061709..6d51e9114baedf5771291eeb1ce933e2ab2193ab 100644
|
| --- a/runtime/bin/file_system_watcher_macos.cc
|
| +++ b/runtime/bin/file_system_watcher_macos.cc
|
| @@ -259,6 +259,7 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id) {
|
| if (bytes < 0) {
|
| return DartUtils::NewDartOSError();
|
| }
|
| + size_t path_len = strlen(e.data.path);
|
| Dart_Handle event = Dart_NewList(3);
|
| int flags = e.data.flags;
|
| int mask = 0;
|
| @@ -266,11 +267,18 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id) {
|
| if (flags & kFSEventStreamEventFlagItemRenamed) mask |= kMove;
|
| if (flags & kFSEventStreamEventFlagItemXattrMod) mask |= kModefyAttribute;
|
| if (flags & kFSEventStreamEventFlagItemCreated) mask |= kCreate;
|
| - if (flags & kFSEventStreamEventFlagItemRemoved) mask |= kDelete;
|
| + if (flags & kFSEventStreamEventFlagItemRemoved) {
|
| + if (path_len == 0) {
|
| + // The removed path is the path being watched.
|
| + mask |= kDeleteSelf;
|
| + } else {
|
| + mask |= kDelete;
|
| + }
|
| + }
|
| Dart_ListSetAt(event, 0, Dart_NewInteger(mask));
|
| Dart_ListSetAt(event, 1, Dart_NewInteger(1));
|
| Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8(
|
| - reinterpret_cast<uint8_t*>(e.data.path), strlen(e.data.path)));
|
| + reinterpret_cast<uint8_t*>(e.data.path), path_len));
|
| Dart_ListSetAt(events, i, event);
|
| }
|
| return events;
|
|
|