diff options
author | isaacs <i@izs.me> | 2012-09-17 15:36:05 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-09-17 15:36:15 -0700 |
commit | b788c5e77b564183826a4ccb69ec9a43a758a54a (patch) | |
tree | 8916ff311d3a7a5ae41022b9c8c198e78e1d55c3 /deps/uv/src/unix/fsevents.c | |
parent | 7144be70db2e6ce337d0f6ec47a28a06802d1c7a (diff) | |
download | android-node-v8-b788c5e77b564183826a4ccb69ec9a43a758a54a.tar.gz android-node-v8-b788c5e77b564183826a4ccb69ec9a43a758a54a.tar.bz2 android-node-v8-b788c5e77b564183826a4ccb69ec9a43a758a54a.zip |
uv: Upgrade to 778144f0
joyent/libuv@778144f0b5bc14fe55d79854d0a67124ceaa4b22
Diffstat (limited to 'deps/uv/src/unix/fsevents.c')
-rw-r--r-- | deps/uv/src/unix/fsevents.c | 56 |
1 files changed, 52 insertions, 4 deletions
diff --git a/deps/uv/src/unix/fsevents.c b/deps/uv/src/unix/fsevents.c index 1a7e06e46c..17dd11afa8 100644 --- a/deps/uv/src/unix/fsevents.c +++ b/deps/uv/src/unix/fsevents.c @@ -66,8 +66,13 @@ void uv__fsevents_cb(uv_async_t* cb, int status) { handle = cb->data; UV__FSEVENTS_WALK(handle, { - if (handle->fd != -1) + if (handle->fd != -1) { +#ifdef MAC_OS_X_VERSION_10_7 handle->cb(handle, event->path, event->events, 0); +#else + handle->cb(handle, NULL, event->events, 0); +#endif /* MAC_OS_X_VERSION_10_7 */ + } }) if ((handle->flags & (UV_CLOSING | UV_CLOSED)) == 0 && handle->fd == -1) @@ -84,6 +89,8 @@ void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, size_t i; int len; char** paths; + char* path; + char* pos; uv_fs_event_t* handle; uv__fsevents_event_t* event; ngx_queue_t add_list; @@ -99,17 +106,50 @@ void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef, kFSEventStreamEventFlagEventIdsWrapped | kFSEventStreamEventFlagHistoryDone | kFSEventStreamEventFlagMount | - kFSEventStreamEventFlagUnmount)) { + kFSEventStreamEventFlagUnmount | + kFSEventStreamEventFlagRootChanged)) { continue; } /* TODO: Report errors */ - len = strlen(paths[i]); + path = paths[i]; + len = strlen(path); + + /* Remove absolute path prefix */ + if (strstr(path, handle->realpath) == path) { + path += handle->realpath_len; + len -= handle->realpath_len; + + /* Skip back slash */ + if (*path != 0) { + path++; + len--; + } + } + +#ifdef MAC_OS_X_VERSION_10_7 + /* Ignore events with path equal to directory itself */ + if (len == 0) + continue; +#endif /* MAC_OS_X_VERSION_10_7 */ + + /* Do not emit events from subdirectories (without option set) */ + pos = strchr(path, '/'); + if ((handle->cf_flags & UV_FS_EVENT_RECURSIVE) == 0 && + pos != NULL && + pos != path + 1) + continue; + +#ifndef MAC_OS_X_VERSION_10_7 + path = ""; + len = 0; +#endif /* MAC_OS_X_VERSION_10_7 */ + event = malloc(sizeof(*event) + len); if (event == NULL) break; - memcpy(event->path, paths[i], len + 1); + memcpy(event->path, path, len + 1); if (eventFlags[i] & kFSEventStreamEventFlagItemModified) event->events = UV_CHANGE; @@ -153,6 +193,11 @@ int uv__fsevents_init(uv_fs_event_t* handle) { ctx.release = NULL; ctx.copyDescription = NULL; + /* Get absolute path to file */ + handle->realpath = realpath(handle->filename, NULL); + if (handle->realpath != NULL) + handle->realpath_len = strlen(handle->realpath); + /* Initialize paths array */ path = CFStringCreateWithCString(NULL, handle->filename, @@ -220,6 +265,9 @@ int uv__fsevents_close(uv_fs_event_t* handle) { uv_mutex_destroy(&handle->cf_mutex); uv_sem_destroy(&handle->cf_sem); + free(handle->realpath); + handle->realpath = NULL; + handle->realpath_len = 0; return 0; } |