| Index: runtime/bin/file_system_watcher_android.cc
|
| diff --git a/runtime/bin/file_system_watcher_android.cc b/runtime/bin/file_system_watcher_android.cc
|
| index ac2ad5f0c9b674d9204e7d0040461f80be25e7c2..ccf54da4fcb868c4ef2d54392e08f70d66a84294 100644
|
| --- a/runtime/bin/file_system_watcher_android.cc
|
| +++ b/runtime/bin/file_system_watcher_android.cc
|
| @@ -11,10 +11,8 @@
|
| #include <sys/inotify.h> // NOLINT
|
|
|
| #include "bin/fdutils.h"
|
| -
|
| #include "platform/signal_blocker.h"
|
|
|
| -
|
| namespace dart {
|
| namespace bin {
|
|
|
| @@ -46,10 +44,18 @@ intptr_t FileSystemWatcher::WatchPath(intptr_t id,
|
| int events,
|
| bool recursive) {
|
| int list_events = IN_DELETE_SELF | IN_MOVE_SELF;
|
| - if (events & kCreate) list_events |= IN_CREATE;
|
| - if (events & kModifyContent) list_events |= IN_CLOSE_WRITE | IN_ATTRIB;
|
| - if (events & kDelete) list_events |= IN_DELETE;
|
| - if (events & kMove) list_events |= IN_MOVE;
|
| + if ((events & kCreate) != 0) {
|
| + list_events |= IN_CREATE;
|
| + }
|
| + if ((events & kModifyContent) != 0) {
|
| + list_events |= IN_CLOSE_WRITE | IN_ATTRIB;
|
| + }
|
| + if ((events & kDelete) != 0) {
|
| + list_events |= IN_DELETE;
|
| + }
|
| + if ((events & kMove) != 0) {
|
| + list_events |= IN_MOVE;
|
| + }
|
| int path_id = NO_RETRY_EXPECTED(inotify_add_watch(id, path, list_events));
|
| if (path_id < 0) {
|
| return -1;
|
| @@ -69,6 +75,33 @@ intptr_t FileSystemWatcher::GetSocketId(intptr_t id, intptr_t path_id) {
|
| }
|
|
|
|
|
| +static int InotifyEventToMask(struct inotify_event* e) {
|
| + int mask = 0;
|
| + if ((e->mask & IN_CLOSE_WRITE) != 0) {
|
| + mask |= FileSystemWatcher::kModifyContent;
|
| + }
|
| + if ((e->mask & IN_ATTRIB) != 0) {
|
| + mask |= FileSystemWatcher::kModefyAttribute;
|
| + }
|
| + if ((e->mask & IN_CREATE) != 0) {
|
| + mask |= FileSystemWatcher::kCreate;
|
| + }
|
| + if ((e->mask & IN_MOVE) != 0) {
|
| + mask |= FileSystemWatcher::kMove;
|
| + }
|
| + if ((e->mask & IN_DELETE) != 0) {
|
| + mask |= FileSystemWatcher::kDelete;
|
| + }
|
| + if ((e->mask & (IN_DELETE_SELF | IN_MOVE_SELF)) != 0) {
|
| + mask |= FileSystemWatcher::kDeleteSelf;
|
| + }
|
| + if ((e->mask & IN_ISDIR) != 0) {
|
| + mask |= FileSystemWatcher::kIsDir;
|
| + }
|
| + return mask;
|
| +}
|
| +
|
| +
|
| Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
|
| USE(path_id);
|
| const intptr_t kEventSize = sizeof(struct inotify_event);
|
| @@ -87,14 +120,7 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
|
| reinterpret_cast<struct inotify_event*>(buffer + offset);
|
| if ((e->mask & IN_IGNORED) == 0) {;
|
| Dart_Handle event = Dart_NewList(5);
|
| - int mask = 0;
|
| - if (e->mask & IN_CLOSE_WRITE) mask |= kModifyContent;
|
| - if (e->mask & IN_ATTRIB) mask |= kModefyAttribute;
|
| - if (e->mask & IN_CREATE) mask |= kCreate;
|
| - if (e->mask & IN_MOVE) mask |= kMove;
|
| - if (e->mask & IN_DELETE) mask |= kDelete;
|
| - if (e->mask & (IN_DELETE_SELF | IN_MOVE_SELF)) mask |= kDeleteSelf;
|
| - if (e->mask & IN_ISDIR) mask |= kIsDir;
|
| + int mask = InotifyEventToMask(e);
|
| Dart_ListSetAt(event, 0, Dart_NewInteger(mask));
|
| Dart_ListSetAt(event, 1, Dart_NewInteger(e->cookie));
|
| if (e->len > 0) {
|
|
|