42 sizeof(
handle->req.u.io.overlapped));
43 if (!ReadDirectoryChangesW(
handle->dir_handle,
47 FILE_NOTIFY_CHANGE_FILE_NAME |
48 FILE_NOTIFY_CHANGE_DIR_NAME |
49 FILE_NOTIFY_CHANGE_ATTRIBUTES |
50 FILE_NOTIFY_CHANGE_SIZE |
51 FILE_NOTIFY_CHANGE_LAST_WRITE |
52 FILE_NOTIFY_CHANGE_LAST_ACCESS |
53 FILE_NOTIFY_CHANGE_CREATION |
54 FILE_NOTIFY_CHANGE_SECURITY,
56 &
handle->req.u.io.overlapped,
70 size_t filenamelen = wcslen(
filename);
71 size_t dirlen = wcslen(dir);
73 if (dirlen > 0 && dir[dirlen - 1] ==
'\\')
75 relpathlen = filenamelen - dirlen - 1;
76 *relpath =
uv__malloc((relpathlen + 1) *
sizeof(WCHAR));
79 wcsncpy(*relpath,
filename + dirlen + 1, relpathlen);
80 (*relpath)[relpathlen] =
L'\0';
101 dir_len = GetCurrentDirectoryW(0,
NULL);
105 *dir = (WCHAR*)
uv__malloc(dir_len *
sizeof(WCHAR));
110 if (!GetCurrentDirectoryW(dir_len, *dir)) {
120 *dir = (WCHAR*)
uv__malloc((
i + 2) *
sizeof(WCHAR));
125 (*dir)[
i + 1] =
L'\0';
133 (*file)[
len -
i - 1] =
L'\0';
159 unsigned int flags) {
160 int name_size, is_path_dir,
size;
161 DWORD attr, last_error;
162 WCHAR* dir =
NULL, *dir_to_watch, *pathw =
NULL;
163 DWORD short_path_buffer_len;
164 WCHAR *short_path_buffer;
165 WCHAR* short_path, *long_path;
181 name_size = MultiByteToWideChar(CP_UTF8, 0,
path, -1,
NULL, 0) *
188 if (!MultiByteToWideChar(CP_UTF8,
193 name_size /
sizeof(WCHAR))) {
198 attr = GetFileAttributesW(pathw);
199 if (attr == INVALID_FILE_ATTRIBUTES) {
200 last_error = GetLastError();
204 is_path_dir = (attr & FILE_ATTRIBUTE_DIRECTORY) ? 1 : 0;
210 size = GetLongPathNameW(pathw,
NULL, 0);
218 size = GetLongPathNameW(pathw, long_path,
size);
220 long_path[
size] =
'\0';
232 dir_to_watch = pathw;
240 short_path_buffer =
NULL;
241 short_path_buffer_len = GetShortPathNameW(pathw,
NULL, 0);
242 if (short_path_buffer_len == 0) {
243 goto short_path_done;
245 short_path_buffer =
uv__malloc(short_path_buffer_len *
sizeof(WCHAR));
246 if (short_path_buffer ==
NULL) {
247 goto short_path_done;
249 if (GetShortPathNameW(pathw,
251 short_path_buffer_len) == 0) {
253 short_path_buffer =
NULL;
256 short_path = short_path_buffer;
259 last_error = GetLastError();
264 last_error = GetLastError();
273 handle->dir_handle = CreateFileW(dir_to_watch,
275 FILE_SHARE_READ | FILE_SHARE_DELETE |
279 FILE_FLAG_BACKUP_SEMANTICS |
280 FILE_FLAG_OVERLAPPED,
289 last_error = GetLastError();
293 if (CreateIoCompletionPort(
handle->dir_handle,
297 last_error = GetLastError();
309 sizeof(
handle->req.u.io.overlapped));
311 if (!ReadDirectoryChangesW(
handle->dir_handle,
315 FILE_NOTIFY_CHANGE_FILE_NAME |
316 FILE_NOTIFY_CHANGE_DIR_NAME |
317 FILE_NOTIFY_CHANGE_ATTRIBUTES |
318 FILE_NOTIFY_CHANGE_SIZE |
319 FILE_NOTIFY_CHANGE_LAST_WRITE |
320 FILE_NOTIFY_CHANGE_LAST_ACCESS |
321 FILE_NOTIFY_CHANGE_CREATION |
322 FILE_NOTIFY_CHANGE_SECURITY,
324 &
handle->req.u.io.overlapped,
326 last_error = GetLastError();
346 if (
handle->short_filew) {
354 CloseHandle(
handle->dir_handle);
377 CloseHandle(
handle->dir_handle);
388 if (
handle->short_filew) {
413 str_len = wcslen(
str);
419 if (str_len != (file_name_len /
sizeof(WCHAR)))
428 FILE_NOTIFY_INFORMATION* file_info;
431 WCHAR* filenamew =
NULL;
432 WCHAR* long_filenamew =
NULL;
450 file_info = (FILE_NOTIFY_INFORMATION*)(
handle->buffer +
offset);
453 if (
req->u.io.overlapped.InternalHigh > 0) {
455 file_info = (FILE_NOTIFY_INFORMATION*)((
char*)file_info +
offset);
467 file_info->FileNameLength) == 0 ||
470 file_info->FileNameLength) == 0) {
479 if (file_info->Action != FILE_ACTION_REMOVED &&
480 file_info->Action != FILE_ACTION_RENAMED_OLD_NAME) {
483 file_info->FileNameLength /
sizeof(WCHAR) + 2;
490 _snwprintf(filenamew,
size,
L"%s\\%.*s",
handle->dirw,
491 file_info->FileNameLength / (
DWORD)
sizeof(WCHAR),
492 file_info->FileName);
494 filenamew[
size - 1] =
L'\0';
497 size = GetLongPathNameW(filenamew,
NULL, 0);
501 if (!long_filenamew) {
505 size = GetLongPathNameW(filenamew, long_filenamew,
size);
507 long_filenamew[
size] =
'\0';
510 long_filenamew =
NULL;
516 if (long_filenamew) {
522 long_filenamew = filenamew;
526 filenamew = file_info->FileName;
527 sizew = file_info->FileNameLength /
sizeof(WCHAR);
535 filenamew = file_info->FileName;
536 sizew = file_info->FileNameLength /
sizeof(WCHAR);
540 filenamew =
handle->filew;
547 switch (file_info->Action) {
548 case FILE_ACTION_ADDED:
549 case FILE_ACTION_REMOVED:
550 case FILE_ACTION_RENAMED_OLD_NAME:
551 case FILE_ACTION_RENAMED_NEW_NAME:
555 case FILE_ACTION_MODIFIED:
563 long_filenamew =
NULL;
567 offset = file_info->NextEntryOffset;
590 if (!
handle->req_pending) {
static mcore_handle handle
static static fork const void static count static fd const char const char static newpath const char static path const char path
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec req
void uv_fatal_error(const int errorno, const char *syscall)
void uv_fs_event_endgame(uv_loop_t *loop, uv_fs_event_t *handle)
static int uv_split_path(const WCHAR *filename, WCHAR **dir, WCHAR **file)
int uv_fs_event_stop(uv_fs_event_t *handle)
int uv_fs_event_start(uv_fs_event_t *handle, uv_fs_event_cb cb, const char *path, unsigned int flags)
int uv_fs_event_init(uv_loop_t *loop, uv_fs_event_t *handle)
const unsigned int uv_directory_watcher_buffer_size
static void uv_relative_path(const WCHAR *filename, const WCHAR *dir, WCHAR **relpath)
static void uv_fs_event_queue_readdirchanges(uv_loop_t *loop, uv_fs_event_t *handle)
static int file_info_cmp(WCHAR *str, WCHAR *file_name, size_t file_name_len)
void uv_process_fs_event_req(uv_loop_t *loop, uv_req_t *req, uv_fs_event_t *handle)
void uv_fs_event_close(uv_loop_t *loop, uv_fs_event_t *handle)
static INLINE void uv_want_endgame(uv_loop_t *loop, uv_handle_t *handle)
#define uv__handle_close(handle)
#define uv__handle_closing(handle)
#define INVALID_HANDLE_VALUE
return memset(p, 0, total)
static const char file_name
assert(limit<=UINT32_MAX/2)
#define GET_REQ_ERROR(req)
static INLINE void uv_insert_pending_req(uv_loop_t *loop, uv_req_t *req)
#define SET_REQ_ERROR(req, error)
static struct sockaddr static addrlen static backlog const void static flags void flags
int uv__convert_utf16_to_utf8(const WCHAR *utf16, int utf16len, char **utf8)
void error(const char *msg)
char * uv__strdup(const char *s)
void * uv__malloc(size_t size)
#define UV_REQ_INIT(req, typ)
#define uv__handle_init(loop_, h, type_)
#define uv__handle_stop(h)
#define uv__handle_start(h)
UV_EXTERN int uv_translate_sys_error(int sys_errno)
void(* uv_fs_event_cb)(uv_fs_event_t *handle, const char *filename, int events, int status)