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

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

Issue 23483030: Make file system watcher compile on Mac OS 106, and add a runtime-call to test if the system suppor… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 | Annotate | Revision Log
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_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/file_system_watcher.h" 8 #include "bin/file_system_watcher.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
11 #include <fcntl.h> // NOLINT 11 #include <fcntl.h> // NOLINT
12 #include <unistd.h> // NOLINT 12 #include <unistd.h> // NOLINT
13 #include <CoreServices/CoreServices.h> // NOLINT 13 #include <CoreServices/CoreServices.h> // NOLINT
14 14
15 #include "bin/eventhandler.h" 15 #include "bin/eventhandler.h"
16 #include "bin/fdutils.h" 16 #include "bin/fdutils.h"
17 #include "bin/socket.h" 17 #include "bin/socket.h"
18 #include "bin/thread.h" 18 #include "bin/thread.h"
19 19
20 20
21 #ifndef MAC_OS_X_VERSION_10_7
22 enum {
23 kFSEventStreamCreateFlagFileEvents = 0x00000010
24 };
25 enum {
26 kFSEventStreamEventFlagItemCreated = 0x00000100,
27 kFSEventStreamEventFlagItemRemoved = 0x00000200,
28 kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400,
29 kFSEventStreamEventFlagItemRenamed = 0x00000800,
30 kFSEventStreamEventFlagItemModified = 0x00001000,
31 kFSEventStreamEventFlagItemFinderInfoMod = 0x00002000,
32 kFSEventStreamEventFlagItemChangeOwner = 0x00004000,
33 kFSEventStreamEventFlagItemXattrMod = 0x00008000,
34 kFSEventStreamEventFlagItemIsFile = 0x00010000,
35 kFSEventStreamEventFlagItemIsDir = 0x00020000,
36 kFSEventStreamEventFlagItemIsSymlink = 0x00040000
37 };
38 #endif
39
40
21 namespace dart { 41 namespace dart {
22 namespace bin { 42 namespace bin {
23 43
24 static Mutex* watcher_mutex = new Mutex(); 44 static Mutex* watcher_mutex = new Mutex();
25 static Monitor* watcher_monitor = new Monitor(); 45 static Monitor* watcher_monitor = new Monitor();
26 46
27 class FSEventsWatcher; 47 class FSEventsWatcher;
28 static FSEventsWatcher* watcher = NULL; 48 static FSEventsWatcher* watcher = NULL;
29 49
30 union FSEvent { 50 union FSEvent {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 memmove(event.data.path, path, strlen(path) + 1); 204 memmove(event.data.path, path, strlen(path) + 1);
185 write(node->write_fd(), event.bytes, sizeof(event)); 205 write(node->write_fd(), event.bytes, sizeof(event));
186 } 206 }
187 } 207 }
188 208
189 CFRunLoopRef run_loop_; 209 CFRunLoopRef run_loop_;
190 int users_; 210 int users_;
191 }; 211 };
192 212
193 213
214 bool FileSystemWatcher::IsSupported() {
215 SInt32 version = 0;
216 Gestalt(gestaltSystemVersion, &version);
kustermann 2013/09/03 15:18:58 Seems like 'Gestalt' is deprecated / will be remov
Anders Johnsen 2013/09/03 15:32:56 Nicely spotted, changed.
217 return version >= 0x1070;
218 }
219
220
194 intptr_t FileSystemWatcher::WatchPath(const char* path, 221 intptr_t FileSystemWatcher::WatchPath(const char* path,
195 int events, 222 int events,
196 bool recursive) { 223 bool recursive) {
197 MutexLocker lock(watcher_mutex); 224 MutexLocker lock(watcher_mutex);
198 FSEventsWatcher::Increment(); 225 FSEventsWatcher::Increment();
199 226
200 FSEventsWatcher::Node* node = watcher->AddPath(path, events, recursive); 227 FSEventsWatcher::Node* node = watcher->AddPath(path, events, recursive);
201 node->Start(); 228 node->Start();
202 return reinterpret_cast<intptr_t>(node); 229 return reinterpret_cast<intptr_t>(node);
203 } 230 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 } 274 }
248 return events; 275 return events;
249 } 276 }
250 277
251 } // namespace bin 278 } // namespace bin
252 } // namespace dart 279 } // namespace dart
253 280
254 #endif // defined(TARGET_OS_MACOS) 281 #endif // defined(TARGET_OS_MACOS)
255 282
256 283
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698