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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
6 | 6 |
7 #include "platform/globals.h" | 7 #include "platform/globals.h" |
8 #if defined(TARGET_OS_LINUX) | 8 #if defined(TARGET_OS_LINUX) |
9 | 9 |
10 #include "bin/file_system_watcher.h" | 10 #include "bin/file_system_watcher.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (bytes < 0) { | 114 if (bytes < 0) { |
115 return DartUtils::NewDartOSError(); | 115 return DartUtils::NewDartOSError(); |
116 } | 116 } |
117 const intptr_t kMaxCount = bytes / kEventSize; | 117 const intptr_t kMaxCount = bytes / kEventSize; |
118 Dart_Handle events = Dart_NewList(kMaxCount); | 118 Dart_Handle events = Dart_NewList(kMaxCount); |
119 intptr_t offset = 0; | 119 intptr_t offset = 0; |
120 intptr_t i = 0; | 120 intptr_t i = 0; |
121 while (offset < bytes) { | 121 while (offset < bytes) { |
122 struct inotify_event* e = | 122 struct inotify_event* e = |
123 reinterpret_cast<struct inotify_event*>(buffer + offset); | 123 reinterpret_cast<struct inotify_event*>(buffer + offset); |
124 if ((e->mask & IN_IGNORED) == 0) {; | 124 if ((e->mask & IN_IGNORED) == 0) { |
125 Dart_Handle event = Dart_NewList(5); | 125 Dart_Handle event = Dart_NewList(5); |
126 int mask = InotifyEventToMask(e); | 126 int mask = InotifyEventToMask(e); |
127 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); | 127 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); |
128 Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie)); | 128 Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie)); |
129 if (e->len > 0) { | 129 if (e->len > 0) { |
130 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8( | 130 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8( |
131 reinterpret_cast<uint8_t*>(e->name), strlen(e->name))); | 131 reinterpret_cast<uint8_t*>(e->name), strlen(e->name))); |
132 } else { | 132 } else { |
133 Dart_ListSetAt(event, 2, Dart_Null()); | 133 Dart_ListSetAt(event, 2, Dart_Null()); |
134 } | 134 } |
135 Dart_ListSetAt(event, 3, Dart_NewBoolean(e->mask & IN_MOVED_TO)); | 135 Dart_ListSetAt(event, 3, Dart_NewBoolean(e->mask & IN_MOVED_TO)); |
136 Dart_ListSetAt(event, 4, Dart_NewInteger(e->wd)); | 136 Dart_ListSetAt(event, 4, Dart_NewInteger(e->wd)); |
137 Dart_ListSetAt(events, i, event); | 137 Dart_ListSetAt(events, i, event); |
138 i++; | 138 i++; |
139 } | 139 } |
140 offset += kEventSize + e->len; | 140 offset += kEventSize + e->len; |
141 } | 141 } |
142 ASSERT(offset == bytes); | 142 ASSERT(offset == bytes); |
143 return events; | 143 return events; |
144 } | 144 } |
145 | 145 |
146 } // namespace bin | 146 } // namespace bin |
147 } // namespace dart | 147 } // namespace dart |
148 | 148 |
149 #endif // defined(TARGET_OS_LINUX) | 149 #endif // defined(TARGET_OS_LINUX) |
150 | 150 |
151 #endif // !defined(DART_IO_DISABLED) | 151 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |