Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(832)

Unified Diff: runtime/bin/file_system_watcher_macos.cc

Issue 39683002: Stop watching when removing watched path, for Mac OS X as well. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698