| Index: runtime/bin/file_system_watcher_macos.cc
|
| diff --git a/runtime/bin/file_system_watcher_macos.cc b/runtime/bin/file_system_watcher_macos.cc
|
| index 5c0d43077a0dd82263f1e5bcfe6b24b9e79725e4..ff6428849ecab1844225f4a5b8eb8a09ebfafcae 100644
|
| --- a/runtime/bin/file_system_watcher_macos.cc
|
| +++ b/runtime/bin/file_system_watcher_macos.cc
|
| @@ -19,10 +19,8 @@
|
| #include "bin/file.h"
|
| #include "bin/socket.h"
|
| #include "bin/thread.h"
|
| -
|
| #include "platform/signal_blocker.h"
|
|
|
| -
|
| #ifndef MAC_OS_X_VERSION_10_7
|
| enum {
|
| kFSEventStreamCreateFlagFileEvents = 0x00000010
|
| @@ -42,7 +40,6 @@ enum {
|
| };
|
| #endif
|
|
|
| -
|
| namespace dart {
|
| namespace bin {
|
|
|
| @@ -55,6 +52,7 @@ union FSEvent {
|
| uint8_t bytes[PATH_MAX + 8];
|
| };
|
|
|
| +
|
| class FSEventsWatcher {
|
| public:
|
| class Node {
|
| @@ -180,6 +178,8 @@ class FSEventsWatcher {
|
| int write_fd_;
|
| bool recursive_;
|
| FSEventStreamRef ref_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(Node);
|
| };
|
|
|
|
|
| @@ -287,15 +287,21 @@ class FSEventsWatcher {
|
| Thread::GetCurrentThreadId()));
|
| // `ready` is set on same thread as this callback is invoked, so we don't
|
| // need to lock here.
|
| - if (!node->ready()) return;
|
| + if (!node->ready()) {
|
| + return;
|
| + }
|
| for (size_t i = 0; i < num_events; i++) {
|
| char *path = reinterpret_cast<char**>(event_paths)[i];
|
| FSEvent event;
|
| event.data.exists = File::GetType(path, false) != File::kDoesNotExist;
|
| path += node->base_path_length();
|
| // If path is longer the base, skip next character ('/').
|
| - if (path[0] != '\0') path += 1;
|
| - if (!node->recursive() && strstr(path, "/") != NULL) continue;
|
| + if (path[0] != '\0') {
|
| + path += 1;
|
| + }
|
| + if (!node->recursive() && (strstr(path, "/") != NULL)) {
|
| + continue;
|
| + }
|
| event.data.flags = event_flags[i];
|
| memmove(event.data.path, path, strlen(path) + 1);
|
| write(node->write_fd(), event.bytes, sizeof(event));
|
| @@ -305,6 +311,8 @@ class FSEventsWatcher {
|
| Monitor monitor_;
|
| CFRunLoopRef run_loop_;
|
| ThreadId threadId_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(FSEventsWatcher);
|
| };
|
|
|
|
|
| @@ -348,7 +356,9 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
|
| intptr_t fd = GetSocketId(id, path_id);
|
| intptr_t avail = FDUtils::AvailableBytes(fd);
|
| int count = avail / sizeof(FSEvent);
|
| - if (count <= 0) return Dart_NewList(0);
|
| + if (count <= 0) {
|
| + return Dart_NewList(0);
|
| + }
|
| Dart_Handle events = Dart_NewList(count);
|
| FSEvent e;
|
| for (int i = 0; i < count; i++) {
|
| @@ -360,7 +370,7 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
|
| Dart_Handle event = Dart_NewList(5);
|
| int flags = e.data.flags;
|
| int mask = 0;
|
| - if (flags & kFSEventStreamEventFlagItemRenamed) {
|
| + if ((flags & kFSEventStreamEventFlagItemRenamed) != 0) {
|
| if (path_len == 0) {
|
| // The moved path is the path being watched.
|
| mask |= kDeleteSelf;
|
| @@ -368,11 +378,19 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
|
| mask |= e.data.exists ? kCreate : kDelete;
|
| }
|
| }
|
| - if (flags & kFSEventStreamEventFlagItemModified) mask |= kModifyContent;
|
| - if (flags & kFSEventStreamEventFlagItemXattrMod) mask |= kModefyAttribute;
|
| - if (flags & kFSEventStreamEventFlagItemCreated) mask |= kCreate;
|
| - if (flags & kFSEventStreamEventFlagItemIsDir) mask |= kIsDir;
|
| - if (flags & kFSEventStreamEventFlagItemRemoved) {
|
| + if ((flags & kFSEventStreamEventFlagItemModified) != 0) {
|
| + mask |= kModifyContent;
|
| + }
|
| + if ((flags & kFSEventStreamEventFlagItemXattrMod) != 0) {
|
| + mask |= kModefyAttribute;
|
| + }
|
| + if ((flags & kFSEventStreamEventFlagItemCreated) != 0) {
|
| + mask |= kCreate;
|
| + }
|
| + if ((flags & kFSEventStreamEventFlagItemIsDir) != 0) {
|
| + mask |= kIsDir;
|
| + }
|
| + if ((flags & kFSEventStreamEventFlagItemRemoved) != 0) {
|
| if (path_len == 0) {
|
| // The removed path is the path being watched.
|
| mask |= kDeleteSelf;
|
| @@ -404,24 +422,30 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
|
| return DartUtils::NewDartOSError();
|
| }
|
|
|
| +
|
| intptr_t FileSystemWatcher::GetSocketId(intptr_t id, intptr_t path_id) {
|
| return -1;
|
| }
|
|
|
| +
|
| bool FileSystemWatcher::IsSupported() {
|
| return false;
|
| }
|
|
|
| +
|
| void FileSystemWatcher::UnwatchPath(intptr_t id, intptr_t path_id) {
|
| }
|
|
|
| +
|
| intptr_t FileSystemWatcher::Init() {
|
| return -1;
|
| }
|
|
|
| +
|
| void FileSystemWatcher::Close(intptr_t id) {
|
| }
|
|
|
| +
|
| intptr_t FileSystemWatcher::WatchPath(intptr_t id,
|
| const char* path,
|
| int events,
|
| @@ -433,5 +457,4 @@ intptr_t FileSystemWatcher::WatchPath(intptr_t id,
|
| } // namespace dart
|
|
|
| #endif // !TARGET_OS_IOS
|
| -
|
| #endif // defined(TARGET_OS_MACOS)
|
|
|