OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
7 | 7 |
8 #include "bin/file_system_watcher.h" | 8 #include "bin/file_system_watcher.h" |
9 | 9 |
10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 FSEvent e; | 260 FSEvent e; |
261 for (int i = 0; i < count; i++) { | 261 for (int i = 0; i < count; i++) { |
262 intptr_t bytes = TEMP_FAILURE_RETRY(read(fd, e.bytes, sizeof(e))); | 262 intptr_t bytes = TEMP_FAILURE_RETRY(read(fd, e.bytes, sizeof(e))); |
263 if (bytes < 0) { | 263 if (bytes < 0) { |
264 return DartUtils::NewDartOSError(); | 264 return DartUtils::NewDartOSError(); |
265 } | 265 } |
266 size_t path_len = strlen(e.data.path); | 266 size_t path_len = strlen(e.data.path); |
267 Dart_Handle event = Dart_NewList(4); | 267 Dart_Handle event = Dart_NewList(4); |
268 int flags = e.data.flags; | 268 int flags = e.data.flags; |
269 int mask = 0; | 269 int mask = 0; |
| 270 if (flags & kFSEventStreamEventFlagItemRenamed) { |
| 271 if (path_len == 0) { |
| 272 // The moved path is the path being watched. |
| 273 mask |= kDeleteSelf; |
| 274 } else { |
| 275 mask |= kMove; |
| 276 } |
| 277 } |
270 if (flags & kFSEventStreamEventFlagItemModified) mask |= kModifyContent; | 278 if (flags & kFSEventStreamEventFlagItemModified) mask |= kModifyContent; |
271 if (flags & kFSEventStreamEventFlagItemRenamed) mask |= kMove; | |
272 if (flags & kFSEventStreamEventFlagItemXattrMod) mask |= kModefyAttribute; | 279 if (flags & kFSEventStreamEventFlagItemXattrMod) mask |= kModefyAttribute; |
273 if (flags & kFSEventStreamEventFlagItemCreated) mask |= kCreate; | 280 if (flags & kFSEventStreamEventFlagItemCreated) mask |= kCreate; |
274 if (flags & kFSEventStreamEventFlagItemIsDir) mask |= kIsDir; | 281 if (flags & kFSEventStreamEventFlagItemIsDir) mask |= kIsDir; |
275 if (flags & kFSEventStreamEventFlagItemRemoved) { | 282 if (flags & kFSEventStreamEventFlagItemRemoved) { |
276 if (path_len == 0) { | 283 if (path_len == 0) { |
277 // The removed path is the path being watched. | 284 // The removed path is the path being watched. |
278 mask |= kDeleteSelf; | 285 mask |= kDeleteSelf; |
279 } else { | 286 } else { |
280 mask |= kDelete; | 287 mask |= kDelete; |
281 } | 288 } |
282 } | 289 } |
283 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); | 290 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); |
284 Dart_ListSetAt(event, 1, Dart_NewInteger(1)); | 291 Dart_ListSetAt(event, 1, Dart_NewInteger(1)); |
285 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8( | 292 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8( |
286 reinterpret_cast<uint8_t*>(e.data.path), path_len)); | 293 reinterpret_cast<uint8_t*>(e.data.path), path_len)); |
287 Dart_ListSetAt(event, 3, Dart_NewBoolean(true)); | 294 Dart_ListSetAt(event, 3, Dart_NewBoolean(true)); |
288 Dart_ListSetAt(events, i, event); | 295 Dart_ListSetAt(events, i, event); |
289 } | 296 } |
290 return events; | 297 return events; |
291 } | 298 } |
292 | 299 |
293 } // namespace bin | 300 } // namespace bin |
294 } // namespace dart | 301 } // namespace dart |
295 | 302 |
296 #endif // defined(TARGET_OS_MACOS) | 303 #endif // defined(TARGET_OS_MACOS) |
297 | 304 |
298 | 305 |
OLD | NEW |