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,
168 if (uv__is_active(handle))
171 handle->cb = cb;
172 handle->path = uv__strdup(path);
173 if (!handle->path) {
177 uv__handle_start(handle);
258 if (uv__split_path(pathw, &dir, &handle->filew) != 0) {
263 if (uv__split_path(short_path, NULL, &handle->short_filew) != 0) {
273 handle->dir_handle = CreateFileW(dir_to_watch,
288 if (handle->dir_handle == INVALID_HANDLE_VALUE) {
293 if (CreateIoCompletionPort(handle->dir_handle,
294 handle->loop->iocp,
295 (ULONG_PTR)handle,
301 if (!handle->buffer) {
302 handle->buffer = (char*)uv__malloc(uv_directory_watcher_buffer_size);
304 if (!handle->buffer) {
308 memset(&(handle->req.u.io.overlapped), 0,
309 sizeof(handle->req.u.io.overlapped));
311 if (!ReadDirectoryChangesW(handle->dir_handle,
312 handle->buffer,
324 &handle->req.u.io.overlapped,
331 handle->dirw = pathw;
332 handle->req_pending = 1;
336 if (handle->path) {
337 uv__free(handle->path);
338 handle->path = NULL;
341 if (handle->filew) {
342 uv__free(handle->filew);
343 handle->filew = NULL;
346 if (handle->short_filew) {
347 uv__free(handle->short_filew);
348 handle->short_filew = NULL;
353 if (handle->dir_handle != INVALID_HANDLE_VALUE) {
354 CloseHandle(handle->dir_handle);
355 handle->dir_handle = INVALID_HANDLE_VALUE;
358 if (handle->buffer) {
359 uv__free(handle->buffer);
360 handle->buffer = NULL;
363 if (uv__is_active(handle))
364 uv__handle_stop(handle);
372 int uv_fs_event_stop(uv_fs_event_t* handle) {
373 if (!uv__is_active(handle))
376 if (handle->dir_handle != INVALID_HANDLE_VALUE) {
377 CloseHandle(handle->dir_handle);
378 handle->dir_handle = INVALID_HANDLE_VALUE;
381 uv__handle_stop(handle);
383 if (handle->filew) {
384 uv__free(handle->filew);
385 handle->filew = NULL;
388 if (handle->short_filew) {
389 uv__free(handle->short_filew);
390 handle->short_filew = NULL;
393 if (handle->path) {
394 uv__free(handle->path);
395 handle->path = NULL;
398 if (handle->dirw) {
399 uv__free(handle->dirw);
400 handle->dirw = NULL;
427 uv_fs_event_t* handle) {
436 assert(handle->req_pending);
437 handle->req_pending = 0;
440 * - We're closing, just push the handle onto the endgame queue
443 if (!uv__is_active(handle)) {
444 if (handle->flags & UV_HANDLE_CLOSING) {
445 uv__want_endgame(loop, (uv_handle_t*) handle);
450 file_info = (FILE_NOTIFY_INFORMATION*)(handle->buffer + offset);
464 if (handle->dirw ||
465 file_info_cmp(handle->filew,
468 file_info_cmp(handle->short_filew,
472 if (handle->dirw) {
482 size = wcslen(handle->dirw) +
490 _snwprintf(filenamew, size, L"%s\\%.*s", handle->dirw,
519 handle->dirw,
540 filenamew = handle->filew;
552 handle->cb(handle, filename, UV_RENAME, 0);
556 handle->cb(handle, filename, UV_CHANGE, 0);
568 } while (offset && !(handle->flags & UV_HANDLE_CLOSING));
570 handle->cb(handle, NULL, UV_CHANGE, 0);
574 handle->cb(handle, NULL, 0, uv_translate_sys_error(err));
577 if (handle->flags & UV_HANDLE_CLOSING) {
578 uv__want_endgame(loop, (uv_handle_t*)handle);
579 } else if (uv__is_active(handle)) {
580 uv__fs_event_queue_readdirchanges(loop, handle);
585 void uv__fs_event_close(uv_loop_t* loop, uv_fs_event_t* handle) {
586 uv_fs_event_stop(handle);
588 uv__handle_closing(handle);
590 if (!handle->req_pending) {
591 uv__want_endgame(loop, (uv_handle_t*)handle);
597 void uv__fs_event_endgame(uv_loop_t* loop, uv_fs_event_t* handle) {
598 if ((handle->flags & UV_HANDLE_CLOSING) && !handle->req_pending) {
599 assert(!(handle->flags & UV_HANDLE_CLOSED));
601 if (handle->buffer) {
602 uv__free(handle->buffer);
603 handle->buffer = NULL;
606 uv__handle_close(handle);