| 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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 int count = avail / sizeof(FSEvent); | 257 int count = avail / sizeof(FSEvent); |
| 258 if (count <= 0) return Dart_NewList(0); | 258 if (count <= 0) return Dart_NewList(0); |
| 259 Dart_Handle events = Dart_NewList(count); | 259 Dart_Handle events = Dart_NewList(count); |
| 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(3); | 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 & kFSEventStreamEventFlagItemModified) mask |= kModifyContent; | 270 if (flags & kFSEventStreamEventFlagItemModified) mask |= kModifyContent; |
| 271 if (flags & kFSEventStreamEventFlagItemRenamed) mask |= kMove; | 271 if (flags & kFSEventStreamEventFlagItemRenamed) mask |= kMove; |
| 272 if (flags & kFSEventStreamEventFlagItemXattrMod) mask |= kModefyAttribute; | 272 if (flags & kFSEventStreamEventFlagItemXattrMod) mask |= kModefyAttribute; |
| 273 if (flags & kFSEventStreamEventFlagItemCreated) mask |= kCreate; | 273 if (flags & kFSEventStreamEventFlagItemCreated) mask |= kCreate; |
| 274 if (flags & kFSEventStreamEventFlagItemRemoved) { | 274 if (flags & kFSEventStreamEventFlagItemRemoved) { |
| 275 if (path_len == 0) { | 275 if (path_len == 0) { |
| 276 // The removed path is the path being watched. | 276 // The removed path is the path being watched. |
| 277 mask |= kDeleteSelf; | 277 mask |= kDeleteSelf; |
| 278 } else { | 278 } else { |
| 279 mask |= kDelete; | 279 mask |= kDelete; |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); | 282 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); |
| 283 Dart_ListSetAt(event, 1, Dart_NewInteger(1)); | 283 Dart_ListSetAt(event, 1, Dart_NewInteger(1)); |
| 284 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8( | 284 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8( |
| 285 reinterpret_cast<uint8_t*>(e.data.path), path_len)); | 285 reinterpret_cast<uint8_t*>(e.data.path), path_len)); |
| 286 Dart_ListSetAt(event, 3, Dart_NewBoolean(true)); |
| 286 Dart_ListSetAt(events, i, event); | 287 Dart_ListSetAt(events, i, event); |
| 287 } | 288 } |
| 288 return events; | 289 return events; |
| 289 } | 290 } |
| 290 | 291 |
| 291 } // namespace bin | 292 } // namespace bin |
| 292 } // namespace dart | 293 } // namespace dart |
| 293 | 294 |
| 294 #endif // defined(TARGET_OS_MACOS) | 295 #endif // defined(TARGET_OS_MACOS) |
| 295 | 296 |
| 296 | 297 |
| OLD | NEW |