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

Side by Side Diff: runtime/bin/file_system_watcher_macos.cc

Issue 48513003: If a move has matching target/destination, signal the event as create or delete. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix list size Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/file_system_watcher_linux.cc ('k') | runtime/bin/file_system_watcher_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « runtime/bin/file_system_watcher_linux.cc ('k') | runtime/bin/file_system_watcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698