diff --git a/include/uv.h b/include/uv.h index f743019c1..d8ee5f1c9 100644 --- a/include/uv.h +++ b/include/uv.h @@ -1893,7 +1893,8 @@ enum uv_fs_event { struct uv_fs_event_s { UV_HANDLE_FIELDS - char* filename; + /* private */ + char* path; UV_FS_EVENT_PRIVATE_FIELDS }; @@ -2029,7 +2030,7 @@ UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, - const char* filename, + const char* path, unsigned int flags); UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); diff --git a/src/unix/fsevents.c b/src/unix/fsevents.c index 7faa1562a..f9c3a400f 100644 --- a/src/unix/fsevents.c +++ b/src/unix/fsevents.c @@ -795,7 +795,7 @@ int uv__fsevents_init(uv_fs_event_t* handle) { return err; /* Get absolute path to file */ - handle->realpath = realpath(handle->filename, NULL); + handle->realpath = realpath(handle->path, NULL); if (handle->realpath == NULL) return -errno; handle->realpath_len = strlen(handle->realpath); diff --git a/src/unix/kqueue.c b/src/unix/kqueue.c index f86f291fc..5a25e117c 100644 --- a/src/unix/kqueue.c +++ b/src/unix/kqueue.c @@ -331,7 +331,7 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, - const char* filename, + const char* path, unsigned int flags) { #if defined(__APPLE__) struct stat statbuf; @@ -342,13 +342,13 @@ int uv_fs_event_start(uv_fs_event_t* handle, return -EINVAL; /* TODO open asynchronously - but how do we report back errors? */ - fd = open(filename, O_RDONLY); + fd = open(path, O_RDONLY); if (fd == -1) return -errno; uv__handle_start(handle); uv__io_init(&handle->event_watcher, uv__fs_event, fd); - handle->filename = strdup(filename); + handle->path = strdup(path); handle->cb = cb; #if defined(__APPLE__) @@ -388,8 +388,8 @@ int uv_fs_event_stop(uv_fs_event_t* handle) { uv__io_stop(handle->loop, &handle->event_watcher, UV__POLLIN); #endif /* defined(__APPLE__) */ - free(handle->filename); - handle->filename = NULL; + free(handle->path); + handle->path = NULL; uv__close(handle->event_watcher.fd); handle->event_watcher.fd = -1; diff --git a/src/unix/linux-inotify.c b/src/unix/linux-inotify.c index 7641f383c..20bc17355 100644 --- a/src/unix/linux-inotify.c +++ b/src/unix/linux-inotify.c @@ -124,7 +124,7 @@ static void uv__inotify_read(uv_loop_t* loop, const char* path; ssize_t size; const char *p; - /* needs to be large enough for sizeof(inotify_event) + strlen(filename) */ + /* needs to be large enough for sizeof(inotify_event) + strlen(path) */ char buf[4096]; while (1) { @@ -219,7 +219,7 @@ int uv_fs_event_start(uv_fs_event_t* handle, no_insert: uv__handle_start(handle); QUEUE_INSERT_TAIL(&w->watchers, &handle->watchers); - handle->filename = w->path; + handle->path = w->path; handle->cb = cb; handle->wd = wd; @@ -237,7 +237,7 @@ int uv_fs_event_stop(uv_fs_event_t* handle) { assert(w != NULL); handle->wd = -1; - handle->filename = NULL; + handle->path = NULL; uv__handle_stop(handle); QUEUE_REMOVE(&handle->watchers); diff --git a/src/unix/sunos.c b/src/unix/sunos.c index 3689138cf..b8a39c701 100644 --- a/src/unix/sunos.c +++ b/src/unix/sunos.c @@ -391,7 +391,7 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, - const char* filename, + const char* path, unsigned int flags) { int portfd; int first_run; @@ -410,12 +410,12 @@ int uv_fs_event_start(uv_fs_event_t* handle, } uv__handle_start(handle); - handle->filename = strdup(filename); + handle->path = strdup(path); handle->fd = PORT_UNUSED; handle->cb = cb; memset(&handle->fo, 0, sizeof handle->fo); - handle->fo.fo_name = handle->filename; + handle->fo.fo_name = handle->path; err = uv__fs_event_rearm(handle); if (err != 0) return err; @@ -440,8 +440,8 @@ int uv_fs_event_stop(uv_fs_event_t* handle) { } handle->fd = PORT_DELETED; - free(handle->filename); - handle->filename = NULL; + free(handle->path); + handle->path = NULL; handle->fo.fo_name = NULL; uv__handle_stop(handle); diff --git a/src/win/fs-event.c b/src/win/fs-event.c index 6132b79c8..f3de57568 100644 --- a/src/win/fs-event.c +++ b/src/win/fs-event.c @@ -126,38 +126,38 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) { int uv_fs_event_start(uv_fs_event_t* handle, uv_fs_event_cb cb, - const char* filename, + const char* path, unsigned int flags) { int name_size, is_path_dir; DWORD attr, last_error; - WCHAR* dir = NULL, *dir_to_watch, *filenamew = NULL; + WCHAR* dir = NULL, *dir_to_watch, *pathw = NULL; WCHAR short_path[MAX_PATH]; if (uv__is_active(handle)) return UV_EINVAL; handle->cb = cb; - handle->filename = strdup(filename); - if (!handle->filename) { + handle->path = strdup(path); + if (!handle->path) { uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); } uv__handle_start(handle); /* Convert name to UTF16. */ - name_size = uv_utf8_to_utf16(filename, NULL, 0) * sizeof(WCHAR); - filenamew = (WCHAR*)malloc(name_size); - if (!filenamew) { + name_size = uv_utf8_to_utf16(path, NULL, 0) * sizeof(WCHAR); + pathw = (WCHAR*)malloc(name_size); + if (!pathw) { uv_fatal_error(ERROR_OUTOFMEMORY, "malloc"); } - if (!uv_utf8_to_utf16(filename, filenamew, + if (!uv_utf8_to_utf16(path, pathw, name_size / sizeof(WCHAR))) { return uv_translate_sys_error(GetLastError()); } - /* Determine whether filename is a file or a directory. */ - attr = GetFileAttributesW(filenamew); + /* Determine whether path is a file or a directory. */ + attr = GetFileAttributesW(pathw); if (attr == INVALID_FILE_ATTRIBUTES) { last_error = GetLastError(); goto error; @@ -166,22 +166,22 @@ int uv_fs_event_start(uv_fs_event_t* handle, is_path_dir = (attr & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0; if (is_path_dir) { - /* filename is a directory, so that's the directory that we will watch. */ - handle->dirw = filenamew; - dir_to_watch = filenamew; + /* path is a directory, so that's the directory that we will watch. */ + handle->dirw = pathw; + dir_to_watch = pathw; } else { /* - * filename is a file. So we split filename into dir & file parts, and + * path is a file. So we split path into dir & file parts, and * watch the dir directory. */ /* Convert to short path. */ - if (!GetShortPathNameW(filenamew, short_path, ARRAY_SIZE(short_path))) { + if (!GetShortPathNameW(pathw, short_path, ARRAY_SIZE(short_path))) { last_error = GetLastError(); goto error; } - if (uv_split_path(filenamew, &dir, &handle->filew) != 0) { + if (uv_split_path(pathw, &dir, &handle->filew) != 0) { last_error = GetLastError(); goto error; } @@ -192,8 +192,8 @@ int uv_fs_event_start(uv_fs_event_t* handle, } dir_to_watch = dir; - free(filenamew); - filenamew = NULL; + free(pathw); + pathw = NULL; } handle->dir_handle = CreateFileW(dir_to_watch, @@ -257,9 +257,9 @@ int uv_fs_event_start(uv_fs_event_t* handle, return 0; error: - if (handle->filename) { - free(handle->filename); - handle->filename = NULL; + if (handle->path) { + free(handle->path); + handle->path = NULL; } if (handle->filew) { @@ -272,7 +272,7 @@ error: handle->short_filew = NULL; } - free(filenamew); + free(pathw); if (handle->dir_handle != INVALID_HANDLE_VALUE) { CloseHandle(handle->dir_handle); @@ -309,9 +309,9 @@ int uv_fs_event_stop(uv_fs_event_t* handle) { handle->short_filew = NULL; } - if (handle->filename) { - free(handle->filename); - handle->filename = NULL; + if (handle->path) { + free(handle->path); + handle->path = NULL; } if (handle->dirw) {