summaryrefslogtreecommitdiff
path: root/deps/uv/src/win/fs-event.c
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-10-07 15:20:33 -0700
committerRyan Dahl <ry@tinyclouds.org>2011-10-07 15:20:35 -0700
commita23d8ad3132ceb1a73fb02bcaf119a11a9d33e85 (patch)
tree026c8ef21ee2daac203749c6acb48c9841a0f14e /deps/uv/src/win/fs-event.c
parent26c08a3f35f251c86a881aa70a8e709216feb03d (diff)
downloadandroid-node-v8-a23d8ad3132ceb1a73fb02bcaf119a11a9d33e85.tar.gz
android-node-v8-a23d8ad3132ceb1a73fb02bcaf119a11a9d33e85.tar.bz2
android-node-v8-a23d8ad3132ceb1a73fb02bcaf119a11a9d33e85.zip
Upgrade libuv to 9f6024a
Fixes #1840
Diffstat (limited to 'deps/uv/src/win/fs-event.c')
-rw-r--r--deps/uv/src/win/fs-event.c71
1 files changed, 51 insertions, 20 deletions
diff --git a/deps/uv/src/win/fs-event.c b/deps/uv/src/win/fs-event.c
index 69cd62d64d..aec7cafd30 100644
--- a/deps/uv/src/win/fs-event.c
+++ b/deps/uv/src/win/fs-event.c
@@ -41,7 +41,8 @@ static void uv_fs_event_init_handle(uv_loop_t* loop, uv_fs_event_t* handle,
handle->buffer = NULL;
handle->req_pending = 0;
handle->filew = NULL;
-
+ handle->short_filew = NULL;
+
uv_req_init(loop, (uv_req_t*)&handle->req);
handle->req.type = UV_FS_EVENT_REQ;
handle->req.data = (void*)handle;
@@ -95,25 +96,29 @@ static int uv_split_path(const wchar_t* filename, wchar_t** dir,
while (i > 0 && filename[--i] != '\\' && filename[i] != '/');
if (i == 0) {
- *dir = (wchar_t*)malloc((MAX_PATH + 1) * sizeof(wchar_t));
- if (!*dir) {
- uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
- }
-
- if (!GetCurrentDirectoryW(MAX_PATH, *dir)) {
- free(*dir);
- *dir = NULL;
- return -1;
+ if (dir) {
+ *dir = (wchar_t*)malloc((MAX_PATH + 1) * sizeof(wchar_t));
+ if (!*dir) {
+ uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
+ }
+
+ if (!GetCurrentDirectoryW(MAX_PATH, *dir)) {
+ free(*dir);
+ *dir = NULL;
+ return -1;
+ }
}
*file = wcsdup(filename);
} else {
- *dir = (wchar_t*)malloc((i + 1) * sizeof(wchar_t));
- if (!*dir) {
- uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
+ if (dir) {
+ *dir = (wchar_t*)malloc((i + 1) * sizeof(wchar_t));
+ if (!*dir) {
+ uv_fatal_error(ERROR_OUTOFMEMORY, "malloc");
+ }
+ wcsncpy(*dir, filename, i);
+ (*dir)[i] = L'\0';
}
- wcsncpy(*dir, filename, i);
- (*dir)[i] = L'\0';
*file = (wchar_t*)malloc((len - i) * sizeof(wchar_t));
if (!*file) {
@@ -132,6 +137,7 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
int name_size;
DWORD attr, last_error;
wchar_t* dir = NULL, *dir_to_watch, *filenamew;
+ wchar_t short_path[MAX_PATH];
uv_fs_event_init_handle(loop, handle, filename, cb);
@@ -165,11 +171,23 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
* filename is a file. So we split filename into dir & file parts, and
* watch the dir directory.
*/
+
+ /* Convert to short path. */
+ if (!GetShortPathNameW(filenamew, short_path, COUNTOF(short_path))) {
+ last_error = GetLastError();
+ goto error;
+ }
+
if (uv_split_path(filenamew, &dir, &handle->filew) != 0) {
last_error = GetLastError();
goto error;
}
+ if (uv_split_path(short_path, NULL, &handle->short_filew) != 0) {
+ last_error = GetLastError();
+ goto error;
+ }
+
dir_to_watch = dir;
}
@@ -194,9 +212,9 @@ int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle,
}
if (CreateIoCompletionPort(handle->dir_handle,
- loop->iocp,
- (ULONG_PTR)handle,
- 0) == NULL) {
+ loop->iocp,
+ (ULONG_PTR)handle,
+ 0) == NULL) {
last_error = GetLastError();
goto error;
}
@@ -242,6 +260,11 @@ error:
handle->filew = NULL;
}
+ if (handle->short_filew) {
+ free(handle->short_filew);
+ handle->short_filew = NULL;
+ }
+
if (handle->dir_handle != INVALID_HANDLE_VALUE) {
CloseHandle(handle->dir_handle);
handle->dir_handle = INVALID_HANDLE_VALUE;
@@ -279,8 +302,11 @@ void uv_process_fs_event_req(uv_loop_t* loop, uv_req_t* req,
* Fire the event only if we were asked to watch a directory,
* or if the filename filter matches.
*/
- if (handle->is_path_dir || _wcsnicmp(handle->filew, file_info->FileName,
- file_info->FileNameLength / sizeof(wchar_t)) == 0) {
+ if (handle->is_path_dir ||
+ _wcsnicmp(handle->filew, file_info->FileName,
+ file_info->FileNameLength / sizeof(wchar_t)) == 0 ||
+ _wcsnicmp(handle->short_filew, file_info->FileName,
+ file_info->FileNameLength / sizeof(wchar_t)) == 0) {
/* Convert the filename to utf8. */
utf8size = uv_utf16_to_utf8(file_info->FileName,
@@ -370,6 +396,11 @@ void uv_fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) {
handle->filew = NULL;
}
+ if (handle->short_filew) {
+ free(handle->short_filew);
+ handle->short_filew = NULL;
+ }
+
if (handle->filename) {
free(handle->filename);
handle->filename = NULL;