| 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 if (bytes < 0) { | 56 if (bytes < 0) { |
| 57 return DartUtils::NewDartOSError(); | 57 return DartUtils::NewDartOSError(); |
| 58 } | 58 } |
| 59 const intptr_t kMaxCount = bytes / kEventSize; | 59 const intptr_t kMaxCount = bytes / kEventSize; |
| 60 Dart_Handle events = Dart_NewList(kMaxCount); | 60 Dart_Handle events = Dart_NewList(kMaxCount); |
| 61 intptr_t offset = 0; | 61 intptr_t offset = 0; |
| 62 intptr_t i = 0; | 62 intptr_t i = 0; |
| 63 while (offset < bytes) { | 63 while (offset < bytes) { |
| 64 struct inotify_event* e = | 64 struct inotify_event* e = |
| 65 reinterpret_cast<struct inotify_event*>(buffer + offset); | 65 reinterpret_cast<struct inotify_event*>(buffer + offset); |
| 66 Dart_Handle event = Dart_NewList(3); | 66 Dart_Handle event = Dart_NewList(4); |
| 67 int mask = 0; | 67 int mask = 0; |
| 68 if (e->mask & IN_MODIFY) mask |= kModifyContent; | 68 if (e->mask & IN_MODIFY) mask |= kModifyContent; |
| 69 if (e->mask & IN_ATTRIB) mask |= kModefyAttribute; | 69 if (e->mask & IN_ATTRIB) mask |= kModefyAttribute; |
| 70 if (e->mask & IN_CREATE) mask |= kCreate; | 70 if (e->mask & IN_CREATE) mask |= kCreate; |
| 71 if (e->mask & IN_MOVE) mask |= kMove; | 71 if (e->mask & IN_MOVE) mask |= kMove; |
| 72 if (e->mask & IN_DELETE) mask |= kDelete; | 72 if (e->mask & IN_DELETE) mask |= kDelete; |
| 73 if (e->mask & IN_DELETE_SELF) mask |= kDeleteSelf; | 73 if (e->mask & IN_DELETE_SELF) mask |= kDeleteSelf; |
| 74 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); | 74 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); |
| 75 Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie)); | 75 Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie)); |
| 76 if (e->len > 0) { | 76 if (e->len > 0) { |
| 77 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8( | 77 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF8( |
| 78 reinterpret_cast<uint8_t*>(e->name), strlen(e->name))); | 78 reinterpret_cast<uint8_t*>(e->name), strlen(e->name))); |
| 79 } else { | 79 } else { |
| 80 Dart_ListSetAt(event, 2, Dart_Null()); | 80 Dart_ListSetAt(event, 2, Dart_Null()); |
| 81 } | 81 } |
| 82 Dart_ListSetAt(event, 3, Dart_NewBoolean(e->mask & IN_MOVED_TO)); |
| 82 Dart_ListSetAt(events, i, event); | 83 Dart_ListSetAt(events, i, event); |
| 83 i++; | 84 i++; |
| 84 offset += kEventSize + e->len; | 85 offset += kEventSize + e->len; |
| 85 } | 86 } |
| 86 ASSERT(offset == bytes); | 87 ASSERT(offset == bytes); |
| 87 return events; | 88 return events; |
| 88 } | 89 } |
| 89 | 90 |
| 90 } // namespace bin | 91 } // namespace bin |
| 91 } // namespace dart | 92 } // namespace dart |
| 92 | 93 |
| 93 #endif // defined(TARGET_OS_LINUX) | 94 #endif // defined(TARGET_OS_LINUX) |
| 94 | 95 |
| OLD | NEW |