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

Unified Diff: runtime/bin/file_system_watcher_macos.cc

Issue 88063002: Don't report file-system move events on Mac OS, and use no-defer to avoid past events. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/io/file_system_entity.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 77fb6a9f20fa7639044e238ad50ca64d5e4aa9b1..2200b78c014d0ada6fe5cad4bed10be65d7265e1 100644
--- a/runtime/bin/file_system_watcher_macos.cc
+++ b/runtime/bin/file_system_watcher_macos.cc
@@ -14,6 +14,7 @@
#include "bin/eventhandler.h"
#include "bin/fdutils.h"
+#include "bin/file.h"
#include "bin/socket.h"
#include "bin/thread.h"
@@ -49,10 +50,11 @@ static FSEventsWatcher* watcher = NULL;
union FSEvent {
struct {
+ uint32_t exists;
uint32_t flags;
char path[PATH_MAX];
} data;
- uint8_t bytes[PATH_MAX + 4];
+ uint8_t bytes[PATH_MAX + 8];
};
class FSEventsWatcher {
@@ -179,7 +181,7 @@ class FSEventsWatcher {
CFArrayCreate(NULL, reinterpret_cast<const void**>(&path_ref), 1, NULL),
kFSEventStreamEventIdSinceNow,
0.10,
- kFSEventStreamCreateFlagFileEvents);
+ kFSEventStreamCreateFlagNoDefer | kFSEventStreamCreateFlagFileEvents);
node->set_ref(ref);
@@ -201,11 +203,12 @@ class FSEventsWatcher {
Node* node = reinterpret_cast<Node*>(client);
for (size_t i = 0; i < num_events; i++) {
char *path = reinterpret_cast<char**>(event_paths)[i];
+ FSEvent event;
+ event.data.exists = File::Exists(path);
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;
- FSEvent event;
event.data.flags = event_flags[i];
memmove(event.data.path, path, strlen(path) + 1);
write(node->write_fd(), event.bytes, sizeof(event));
@@ -272,7 +275,7 @@ Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id) {
// The moved path is the path being watched.
mask |= kDeleteSelf;
} else {
- mask |= kMove;
+ mask |= e.data.exists ? kCreate : kDelete;
}
}
if (flags & kFSEventStreamEventFlagItemModified) mask |= kModifyContent;
« no previous file with comments | « no previous file | sdk/lib/io/file_system_entity.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698