OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
6 | 6 |
7 #include "platform/globals.h" | 7 #include "platform/globals.h" |
8 #if defined(TARGET_OS_WINDOWS) | 8 #if defined(TARGET_OS_WINDOWS) |
9 | 9 |
10 #include "bin/file_system_watcher.h" | 10 #include "bin/file_system_watcher.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 USE(id); | 34 USE(id); |
35 } | 35 } |
36 | 36 |
37 | 37 |
38 intptr_t FileSystemWatcher::WatchPath(intptr_t id, | 38 intptr_t FileSystemWatcher::WatchPath(intptr_t id, |
39 const char* path, | 39 const char* path, |
40 int events, | 40 int events, |
41 bool recursive) { | 41 bool recursive) { |
42 USE(id); | 42 USE(id); |
43 Utf8ToWideScope name(path); | 43 Utf8ToWideScope name(path); |
44 HANDLE dir = CreateFileW(name.wide(), | 44 HANDLE dir = CreateFileW( |
45 FILE_LIST_DIRECTORY, | 45 name.wide(), FILE_LIST_DIRECTORY, |
46 FILE_SHARE_READ | | 46 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, |
47 FILE_SHARE_WRITE | | 47 OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, NULL); |
48 FILE_SHARE_DELETE, | |
49 NULL, | |
50 OPEN_EXISTING, | |
51 FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, | |
52 NULL); | |
53 | 48 |
54 if (dir == INVALID_HANDLE_VALUE) { | 49 if (dir == INVALID_HANDLE_VALUE) { |
55 return -1; | 50 return -1; |
56 } | 51 } |
57 | 52 |
58 int list_events = 0; | 53 int list_events = 0; |
59 if ((events & (kCreate | kMove | kDelete)) != 0) { | 54 if ((events & (kCreate | kMove | kDelete)) != 0) { |
60 list_events |= FILE_NOTIFY_CHANGE_FILE_NAME | | 55 list_events |= FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME; |
61 FILE_NOTIFY_CHANGE_DIR_NAME; | |
62 } | 56 } |
63 if ((events & kModifyContent) != 0) { | 57 if ((events & kModifyContent) != 0) { |
64 list_events |= FILE_NOTIFY_CHANGE_LAST_WRITE; | 58 list_events |= FILE_NOTIFY_CHANGE_LAST_WRITE; |
65 } | 59 } |
66 | 60 |
67 DirectoryWatchHandle* handle = | 61 DirectoryWatchHandle* handle = |
68 new DirectoryWatchHandle(dir, list_events, recursive); | 62 new DirectoryWatchHandle(dir, list_events, recursive); |
69 // Issue a read directly, to be sure events are tracked from now on. This is | 63 // Issue a read directly, to be sure events are tracked from now on. This is |
70 // okay, since in Dart, we create the socket and start reading immidiately. | 64 // okay, since in Dart, we create the socket and start reading immidiately. |
71 handle->EnsureInitialized(EventHandler::delegate()); | 65 handle->EnsureInitialized(EventHandler::delegate()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 if (e->Action == FILE_ACTION_RENAMED_OLD_NAME) { | 111 if (e->Action == FILE_ACTION_RENAMED_OLD_NAME) { |
118 mask |= kMove; | 112 mask |= kMove; |
119 } | 113 } |
120 if (e->Action == FILE_ACTION_RENAMED_NEW_NAME) { | 114 if (e->Action == FILE_ACTION_RENAMED_NEW_NAME) { |
121 mask |= kMove; | 115 mask |= kMove; |
122 } | 116 } |
123 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); | 117 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); |
124 // Move events come in pairs. Just 'enable' by default. | 118 // Move events come in pairs. Just 'enable' by default. |
125 Dart_ListSetAt(event, 1, Dart_NewInteger(1)); | 119 Dart_ListSetAt(event, 1, Dart_NewInteger(1)); |
126 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF16( | 120 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF16( |
127 reinterpret_cast<uint16_t*>(e->FileName), e->FileNameLength / 2)); | 121 reinterpret_cast<uint16_t*>(e->FileName), |
| 122 e->FileNameLength / 2)); |
128 Dart_ListSetAt(event, 3, Dart_NewBoolean(true)); | 123 Dart_ListSetAt(event, 3, Dart_NewBoolean(true)); |
129 Dart_ListSetAt(event, 4, Dart_NewInteger(path_id)); | 124 Dart_ListSetAt(event, 4, Dart_NewInteger(path_id)); |
130 Dart_ListSetAt(events, i, event); | 125 Dart_ListSetAt(events, i, event); |
131 i++; | 126 i++; |
132 if (e->NextEntryOffset == 0) { | 127 if (e->NextEntryOffset == 0) { |
133 break; | 128 break; |
134 } | 129 } |
135 offset += e->NextEntryOffset; | 130 offset += e->NextEntryOffset; |
136 } | 131 } |
137 return events; | 132 return events; |
138 } | 133 } |
139 | 134 |
140 } // namespace bin | 135 } // namespace bin |
141 } // namespace dart | 136 } // namespace dart |
142 | 137 |
143 #endif // defined(TARGET_OS_WINDOWS) | 138 #endif // defined(TARGET_OS_WINDOWS) |
144 | 139 |
145 #endif // !defined(DART_IO_DISABLED) | 140 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |