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

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

Issue 3001963002: [dart:io] Namespaces for file IO (Closed)
Patch Set: Fuchsia fix Created 3 years, 3 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_linux.cc ('k') | runtime/bin/file_system_watcher_win.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(HOST_OS_MACOS) 6 #if defined(HOST_OS_MACOS)
7 7
8 #include "bin/file_system_watcher.h" 8 #include "bin/file_system_watcher.h"
9 9
10 #if !HOST_OS_IOS 10 #if !HOST_OS_IOS
11 11
12 #include <CoreServices/CoreServices.h> // NOLINT 12 #include <CoreServices/CoreServices.h> // NOLINT
13 #include <errno.h> // NOLINT 13 #include <errno.h> // NOLINT
14 #include <fcntl.h> // NOLINT 14 #include <fcntl.h> // NOLINT
15 #include <unistd.h> // NOLINT 15 #include <unistd.h> // NOLINT
16 16
17 #include "bin/eventhandler.h" 17 #include "bin/eventhandler.h"
18 #include "bin/fdutils.h" 18 #include "bin/fdutils.h"
19 #include "bin/file.h" 19 #include "bin/file.h"
20 #include "bin/namespace.h"
20 #include "bin/socket.h" 21 #include "bin/socket.h"
21 #include "bin/thread.h" 22 #include "bin/thread.h"
22 #include "platform/signal_blocker.h" 23 #include "platform/signal_blocker.h"
23 24
24 #ifndef MAC_OS_X_VERSION_10_7 25 #ifndef MAC_OS_X_VERSION_10_7
25 enum { kFSEventStreamCreateFlagFileEvents = 0x00000010 }; 26 enum { kFSEventStreamCreateFlagFileEvents = 0x00000010 };
26 enum { 27 enum {
27 kFSEventStreamEventFlagItemCreated = 0x00000100, 28 kFSEventStreamEventFlagItemCreated = 0x00000100,
28 kFSEventStreamEventFlagItemRemoved = 0x00000200, 29 kFSEventStreamEventFlagItemRemoved = 0x00000200,
29 kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400, 30 kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400,
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 ASSERT(Thread::Compare(node->watcher()->threadId_, 267 ASSERT(Thread::Compare(node->watcher()->threadId_,
267 Thread::GetCurrentThreadId())); 268 Thread::GetCurrentThreadId()));
268 // `ready` is set on same thread as this callback is invoked, so we don't 269 // `ready` is set on same thread as this callback is invoked, so we don't
269 // need to lock here. 270 // need to lock here.
270 if (!node->ready()) { 271 if (!node->ready()) {
271 return; 272 return;
272 } 273 }
273 for (size_t i = 0; i < num_events; i++) { 274 for (size_t i = 0; i < num_events; i++) {
274 char* path = reinterpret_cast<char**>(event_paths)[i]; 275 char* path = reinterpret_cast<char**>(event_paths)[i];
275 FSEvent event; 276 FSEvent event;
276 event.data.exists = File::GetType(path, false) != File::kDoesNotExist; 277 event.data.exists =
278 File::GetType(NULL, path, false) != File::kDoesNotExist;
277 path += node->base_path_length(); 279 path += node->base_path_length();
278 // If path is longer the base, skip next character ('/'). 280 // If path is longer the base, skip next character ('/').
279 if (path[0] != '\0') { 281 if (path[0] != '\0') {
280 path += 1; 282 path += 1;
281 } 283 }
282 if (!node->recursive() && (strstr(path, "/") != NULL)) { 284 if (!node->recursive() && (strstr(path, "/") != NULL)) {
283 continue; 285 continue;
284 } 286 }
285 event.data.flags = event_flags[i]; 287 event.data.flags = event_flags[i];
286 memmove(event.data.path, path, strlen(path) + 1); 288 memmove(event.data.path, path, strlen(path) + 1);
(...skipping 15 matching lines...) Expand all
302 304
303 intptr_t FileSystemWatcher::Init() { 305 intptr_t FileSystemWatcher::Init() {
304 return reinterpret_cast<intptr_t>(new FSEventsWatcher()); 306 return reinterpret_cast<intptr_t>(new FSEventsWatcher());
305 } 307 }
306 308
307 void FileSystemWatcher::Close(intptr_t id) { 309 void FileSystemWatcher::Close(intptr_t id) {
308 delete reinterpret_cast<FSEventsWatcher*>(id); 310 delete reinterpret_cast<FSEventsWatcher*>(id);
309 } 311 }
310 312
311 intptr_t FileSystemWatcher::WatchPath(intptr_t id, 313 intptr_t FileSystemWatcher::WatchPath(intptr_t id,
314 Namespace* namespc,
312 const char* path, 315 const char* path,
313 int events, 316 int events,
314 bool recursive) { 317 bool recursive) {
315 FSEventsWatcher* watcher = reinterpret_cast<FSEventsWatcher*>(id); 318 FSEventsWatcher* watcher = reinterpret_cast<FSEventsWatcher*>(id);
316 return reinterpret_cast<intptr_t>(watcher->AddPath(path, events, recursive)); 319 return reinterpret_cast<intptr_t>(watcher->AddPath(path, events, recursive));
317 } 320 }
318 321
319 void FileSystemWatcher::UnwatchPath(intptr_t id, intptr_t path_id) { 322 void FileSystemWatcher::UnwatchPath(intptr_t id, intptr_t path_id) {
320 USE(id); 323 USE(id);
321 delete reinterpret_cast<FSEventsWatcher::Node*>(path_id); 324 delete reinterpret_cast<FSEventsWatcher::Node*>(path_id);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 int events, 420 int events,
418 bool recursive) { 421 bool recursive) {
419 return -1; 422 return -1;
420 } 423 }
421 424
422 } // namespace bin 425 } // namespace bin
423 } // namespace dart 426 } // namespace dart
424 427
425 #endif // !HOST_OS_IOS 428 #endif // !HOST_OS_IOS
426 #endif // defined(HOST_OS_MACOS) 429 #endif // defined(HOST_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/file_system_watcher_linux.cc ('k') | runtime/bin/file_system_watcher_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698