Lines Matching refs:handle
29 #include "handle-inl.h"
37 uv_fs_event_t* handle) {
38 assert(handle->dir_handle != INVALID_HANDLE_VALUE);
39 assert(!handle->req_pending);
41 memset(&(handle->req.u.io.overlapped), 0,
42 sizeof(handle->req.u.io.overlapped));
43 if (!ReadDirectoryChangesW(handle->dir_handle,
44 handle->buffer,
46 (handle->flags & UV_FS_EVENT_RECURSIVE) ? TRUE : FALSE,
56 &handle->req.u.io.overlapped,
59 SET_REQ_ERROR(&handle->req, GetLastError());
60 uv__insert_pending_req(loop, (uv_req_t*)&handle->req);
63 handle->req_pending = 1;
140 int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle) {
141 uv__handle_init(loop, (uv_handle_t*) handle, UV_FS_EVENT);
142 handle->dir_handle = INVALID_HANDLE_VALUE;
143 handle->buffer = NULL;
144 handle->req_pending = 0;
145 handle->filew = NULL;
146 handle->short_filew = NULL;
147 handle->dirw = NULL;
149 UV_REQ_INIT(&handle->req, UV_FS_EVENT_REQ);
150 handle->req.data = handle;
156 int uv_fs_event_start(uv_fs_event_t* handle,
169 if (uv__is_active(handle))
172 handle->cb = cb;
173 handle->path = uv__strdup(path);
174 if (!handle->path) {
178 uv__handle_start(handle);
245 if (uv__split_path(pathw, &dir, &handle->filew) != 0) {
250 if (uv__split_path(short_path, NULL, &handle->short_filew) != 0) {
260 handle->dir_handle = CreateFileW(dir_to_watch,
275 if (handle->dir_handle == INVALID_HANDLE_VALUE) {
280 if (CreateIoCompletionPort(handle->dir_handle,
281 handle->loop->iocp,
282 (ULONG_PTR)handle,
288 if (!handle->buffer) {
289 handle->buffer = (char*)uv__malloc(uv_directory_watcher_buffer_size);
291 if (!handle->buffer) {
295 memset(&(handle->req.u.io.overlapped), 0,
296 sizeof(handle->req.u.io.overlapped));
298 if (!ReadDirectoryChangesW(handle->dir_handle,
299 handle->buffer,
311 &handle->req.u.io.overlapped,
318 handle->dirw = pathw;
319 handle->req_pending = 1;
326 if (handle->path) {
327 uv__free(handle->path);
328 handle->path = NULL;
331 if (handle->filew) {
332 uv__free(handle->filew);
333 handle->filew = NULL;
336 if (handle->short_filew) {
337 uv__free(handle->short_filew);
338 handle->short_filew = NULL;
343 if (handle->dir_handle != INVALID_HANDLE_VALUE) {
344 CloseHandle(handle->dir_handle);
345 handle->dir_handle = INVALID_HANDLE_VALUE;
348 if (handle->buffer) {
349 uv__free(handle->buffer);
350 handle->buffer = NULL;
353 if (uv__is_active(handle))
354 uv__handle_stop(handle);
362 int uv_fs_event_stop(uv_fs_event_t* handle) {
363 if (!uv__is_active(handle))
366 if (handle->dir_handle != INVALID_HANDLE_VALUE) {
367 CloseHandle(handle->dir_handle);
368 handle->dir_handle = INVALID_HANDLE_VALUE;
371 uv__handle_stop(handle);
373 if (handle->filew) {
374 uv__free(handle->filew);
375 handle->filew = NULL;
378 if (handle->short_filew) {
379 uv__free(handle->short_filew);
380 handle->short_filew = NULL;
383 if (handle->path) {
384 uv__free(handle->path);
385 handle->path = NULL;
388 if (handle->dirw) {
389 uv__free(handle->dirw);
390 handle->dirw = NULL;
417 uv_fs_event_t* handle) {
426 assert(handle->req_pending);
427 handle->req_pending = 0;
430 * - We're closing, just push the handle onto the endgame queue
433 if (!uv__is_active(handle)) {
434 if (handle->flags & UV_HANDLE_CLOSING) {
435 uv__want_endgame(loop, (uv_handle_t*) handle);
440 file_info = (FILE_NOTIFY_INFORMATION*)(handle->buffer + offset);
454 if (handle->dirw ||
455 file_info_cmp(handle->filew,
458 file_info_cmp(handle->short_filew,
462 if (handle->dirw) {
472 size = wcslen(handle->dirw) +
480 _snwprintf(filenamew, size, L"%s\\%.*s", handle->dirw,
509 handle->dirw,
530 filenamew = handle->filew;
542 handle->cb(handle, filename, UV_RENAME, 0);
546 handle->cb(handle, filename, UV_CHANGE, 0);
558 } while (offset && !(handle->flags & UV_HANDLE_CLOSING));
560 handle->cb(handle, NULL, UV_CHANGE, 0);
564 handle->cb(handle, NULL, 0, uv_translate_sys_error(err));
567 if (handle->flags & UV_HANDLE_CLOSING) {
568 uv__want_endgame(loop, (uv_handle_t*)handle);
569 } else if (uv__is_active(handle)) {
570 uv__fs_event_queue_readdirchanges(loop, handle);
575 void uv__fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) {
576 uv_fs_event_stop(handle);
578 uv__handle_closing(handle);
580 if (!handle->req_pending) {
581 uv__want_endgame(loop, (uv_handle_t*)handle);
587 void uv__fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) {
588 if ((handle->flags & UV_HANDLE_CLOSING) && !handle->req_pending) {
589 assert(!(handle->flags & UV_HANDLE_CLOSED));
591 if (handle->buffer) {
592 uv__free(handle->buffer);
593 handle->buffer = NULL;
596 uv__handle_close(handle);