Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: runtime/bin/file_system_watcher_win.cc

Issue 1800863002: Cleanup in //runtime/bin (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/bin/file_system_watcher_macos.cc ('k') | runtime/bin/file_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_WINDOWS) 6 #if defined(TARGET_OS_WINDOWS)
7 7
8 #include "bin/file_system_watcher.h" 8 #include "bin/file_system_watcher.h"
9 #include "bin/eventhandler.h"
10 9
11 #include <WinIoCtl.h> // NOLINT 10 #include <WinIoCtl.h> // NOLINT
12 11
13 #include "bin/builtin.h" 12 #include "bin/builtin.h"
13 #include "bin/eventhandler.h"
14 #include "bin/log.h" 14 #include "bin/log.h"
15 #include "bin/utils.h" 15 #include "bin/utils.h"
16 #include "bin/utils_win.h" 16 #include "bin/utils_win.h"
17 17
18
19 namespace dart { 18 namespace dart {
20 namespace bin { 19 namespace bin {
21 20
22 bool FileSystemWatcher::IsSupported() { 21 bool FileSystemWatcher::IsSupported() {
23 return true; 22 return true;
24 } 23 }
25 24
26 25
27 intptr_t FileSystemWatcher::Init() { 26 intptr_t FileSystemWatcher::Init() {
28 return 0; 27 return 0;
(...skipping 19 matching lines...) Expand all
48 NULL, 47 NULL,
49 OPEN_EXISTING, 48 OPEN_EXISTING,
50 FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, 49 FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
51 NULL); 50 NULL);
52 51
53 if (dir == INVALID_HANDLE_VALUE) { 52 if (dir == INVALID_HANDLE_VALUE) {
54 return -1; 53 return -1;
55 } 54 }
56 55
57 int list_events = 0; 56 int list_events = 0;
58 if (events & (kCreate | kMove | kDelete)) { 57 if ((events & (kCreate | kMove | kDelete)) != 0) {
59 list_events |= FILE_NOTIFY_CHANGE_FILE_NAME | 58 list_events |= FILE_NOTIFY_CHANGE_FILE_NAME |
60 FILE_NOTIFY_CHANGE_DIR_NAME; 59 FILE_NOTIFY_CHANGE_DIR_NAME;
61 } 60 }
62 if (events & kModifyContent) list_events |= FILE_NOTIFY_CHANGE_LAST_WRITE; 61 if ((events & kModifyContent) != 0) {
62 list_events |= FILE_NOTIFY_CHANGE_LAST_WRITE;
63 }
63 64
64 DirectoryWatchHandle* handle = 65 DirectoryWatchHandle* handle =
65 new DirectoryWatchHandle(dir, list_events, recursive); 66 new DirectoryWatchHandle(dir, list_events, recursive);
66 // Issue a read directly, to be sure events are tracked from now on. This is 67 // Issue a read directly, to be sure events are tracked from now on. This is
67 // okay, since in Dart, we create the socket and start reading immidiately. 68 // okay, since in Dart, we create the socket and start reading immidiately.
68 handle->EnsureInitialized(EventHandler::delegate()); 69 handle->EnsureInitialized(EventHandler::delegate());
69 handle->IssueRead(); 70 handle->IssueRead();
70 return reinterpret_cast<intptr_t>(handle); 71 return reinterpret_cast<intptr_t>(handle);
71 } 72 }
72 73
(...skipping 22 matching lines...) Expand all
95 uint8_t* buffer = Dart_ScopeAllocate(available); 96 uint8_t* buffer = Dart_ScopeAllocate(available);
96 intptr_t bytes = dir->Read(buffer, available); 97 intptr_t bytes = dir->Read(buffer, available);
97 intptr_t offset = 0; 98 intptr_t offset = 0;
98 intptr_t i = 0; 99 intptr_t i = 0;
99 while (offset < bytes) { 100 while (offset < bytes) {
100 FILE_NOTIFY_INFORMATION* e = 101 FILE_NOTIFY_INFORMATION* e =
101 reinterpret_cast<FILE_NOTIFY_INFORMATION*>(buffer + offset); 102 reinterpret_cast<FILE_NOTIFY_INFORMATION*>(buffer + offset);
102 103
103 Dart_Handle event = Dart_NewList(5); 104 Dart_Handle event = Dart_NewList(5);
104 int mask = 0; 105 int mask = 0;
105 if (e->Action == FILE_ACTION_ADDED) mask |= kCreate; 106 if (e->Action == FILE_ACTION_ADDED) {
106 if (e->Action == FILE_ACTION_REMOVED) mask |= kDelete; 107 mask |= kCreate;
107 if (e->Action == FILE_ACTION_MODIFIED) mask |= kModifyContent; 108 }
108 if (e->Action == FILE_ACTION_RENAMED_OLD_NAME) mask |= kMove; 109 if (e->Action == FILE_ACTION_REMOVED) {
109 if (e->Action == FILE_ACTION_RENAMED_NEW_NAME) mask |= kMove; 110 mask |= kDelete;
111 }
112 if (e->Action == FILE_ACTION_MODIFIED) {
113 mask |= kModifyContent;
114 }
115 if (e->Action == FILE_ACTION_RENAMED_OLD_NAME) {
116 mask |= kMove;
117 }
118 if (e->Action == FILE_ACTION_RENAMED_NEW_NAME) {
119 mask |= kMove;
120 }
110 Dart_ListSetAt(event, 0, Dart_NewInteger(mask)); 121 Dart_ListSetAt(event, 0, Dart_NewInteger(mask));
111 // Move events come in pairs. Just 'enable' by default. 122 // Move events come in pairs. Just 'enable' by default.
112 Dart_ListSetAt(event, 1, Dart_NewInteger(1)); 123 Dart_ListSetAt(event, 1, Dart_NewInteger(1));
113 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF16( 124 Dart_ListSetAt(event, 2, Dart_NewStringFromUTF16(
114 reinterpret_cast<uint16_t*>(e->FileName), e->FileNameLength / 2)); 125 reinterpret_cast<uint16_t*>(e->FileName), e->FileNameLength / 2));
115 Dart_ListSetAt(event, 3, Dart_NewBoolean(true)); 126 Dart_ListSetAt(event, 3, Dart_NewBoolean(true));
116 Dart_ListSetAt(event, 4, Dart_NewInteger(path_id)); 127 Dart_ListSetAt(event, 4, Dart_NewInteger(path_id));
117 Dart_ListSetAt(events, i, event); 128 Dart_ListSetAt(events, i, event);
118 i++; 129 i++;
119 if (e->NextEntryOffset == 0) break; 130 if (e->NextEntryOffset == 0) {
131 break;
132 }
120 offset += e->NextEntryOffset; 133 offset += e->NextEntryOffset;
121 } 134 }
122 return events; 135 return events;
123 } 136 }
124 137
125 } // namespace bin 138 } // namespace bin
126 } // namespace dart 139 } // namespace dart
127 140
128 #endif // defined(TARGET_OS_WINDOWS) 141 #endif // defined(TARGET_OS_WINDOWS)
OLDNEW
« no previous file with comments | « runtime/bin/file_system_watcher_macos.cc ('k') | runtime/bin/file_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698