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

Side by Side Diff: runtime/bin/file_system_watcher_android.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_patch.dart ('k') | runtime/bin/file_system_watcher_linux.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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 if (bytes < 0) { 60 if (bytes < 0) {
61 return DartUtils::NewDartOSError(); 61 return DartUtils::NewDartOSError();
62 } 62 }
63 const intptr_t kMaxCount = kBufferSize / kEventSize + 1; 63 const intptr_t kMaxCount = kBufferSize / kEventSize + 1;
64 Dart_Handle events = Dart_NewList(kMaxCount); 64 Dart_Handle events = Dart_NewList(kMaxCount);
65 intptr_t offset = 0; 65 intptr_t offset = 0;
66 intptr_t i = 0; 66 intptr_t i = 0;
67 while (offset < bytes) { 67 while (offset < bytes) {
68 struct inotify_event* e = 68 struct inotify_event* e =
69 reinterpret_cast<struct inotify_event*>(buffer + offset); 69 reinterpret_cast<struct inotify_event*>(buffer + offset);
70 Dart_Handle event = Dart_NewList(3); 70 Dart_Handle event = Dart_NewList(4);
71 int mask = 0; 71 int mask = 0;
72 if (e->mask & IN_MODIFY) mask |= kModifyContent; 72 if (e->mask & IN_MODIFY) mask |= kModifyContent;
73 if (e->mask & IN_ATTRIB) mask |= kModefyAttribute; 73 if (e->mask & IN_ATTRIB) mask |= kModefyAttribute;
74 if (e->mask & IN_CREATE) mask |= kCreate; 74 if (e->mask & IN_CREATE) mask |= kCreate;
75 if (e->mask & IN_MOVE) mask |= kMove; 75 if (e->mask & IN_MOVE) mask |= kMove;
76 if (e->mask & IN_DELETE) mask |= kDelete; 76 if (e->mask & IN_DELETE) mask |= kDelete;
77 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); 77 Dart_ListSetAt(event, 0, Dart_NewInteger(mask));
78 Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie)); 78 Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie));
79 if (e->len > 0) { 79 if (e->len > 0) {
80 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8( 80 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8(
81 reinterpret_cast<uint8_t*>(e->name), strlen(e->name))); 81 reinterpret_cast<uint8_t*>(e->name), strlen(e->name)));
82 } else { 82 } else {
83 Dart_ListSetAt(event, 2, Dart_Null()); 83 Dart_ListSetAt(event, 2, Dart_Null());
84 } 84 }
85 Dart_ListSetAt(event, 3, Dart_NewBoolean(e->mask & IN_MOVED_TO));
85 Dart_ListSetAt(events, i, event); 86 Dart_ListSetAt(events, i, event);
86 i++; 87 i++;
87 offset += kEventSize + e->len; 88 offset += kEventSize + e->len;
88 } 89 }
89 ASSERT(offset == bytes); 90 ASSERT(offset == bytes);
90 return events; 91 return events;
91 } 92 }
92 93
93 } // namespace bin 94 } // namespace bin
94 } // namespace dart 95 } // namespace dart
95 96
96 #endif // defined(TARGET_OS_ANDROID) 97 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/file_patch.dart ('k') | runtime/bin/file_system_watcher_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698