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 library watcher.directory_watcher; | 5 library watcher.directory_watcher; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:io'; | 8 import 'dart:io'; |
9 | 9 |
10 import 'watch_event.dart'; | 10 import 'watch_event.dart'; |
11 import 'directory_watcher/linux.dart'; | 11 import 'directory_watcher/linux.dart'; |
| 12 import 'directory_watcher/mac_os.dart'; |
12 import 'directory_watcher/polling.dart'; | 13 import 'directory_watcher/polling.dart'; |
13 | 14 |
14 /// Watches the contents of a directory and emits [WatchEvent]s when something | 15 /// Watches the contents of a directory and emits [WatchEvent]s when something |
15 /// in the directory has changed. | 16 /// in the directory has changed. |
16 abstract class DirectoryWatcher { | 17 abstract class DirectoryWatcher { |
17 /// The directory whose contents are being monitored. | 18 /// The directory whose contents are being monitored. |
18 String get directory; | 19 String get directory; |
19 | 20 |
20 /// The broadcast [Stream] of events that have occurred to files in | 21 /// The broadcast [Stream] of events that have occurred to files in |
21 /// [directory]. | 22 /// [directory]. |
(...skipping 25 matching lines...) Expand all Loading... |
47 /// If a native directory watcher is available for this platform, this will | 48 /// If a native directory watcher is available for this platform, this will |
48 /// use it. Otherwise, it will fall back to a [PollingDirectoryWatcher]. | 49 /// use it. Otherwise, it will fall back to a [PollingDirectoryWatcher]. |
49 /// | 50 /// |
50 /// If [_pollingDelay] is passed, it specifies the amount of time the watcher | 51 /// If [_pollingDelay] is passed, it specifies the amount of time the watcher |
51 /// will pause between successive polls of the directory contents. Making this | 52 /// will pause between successive polls of the directory contents. Making this |
52 /// shorter will give more immediate feedback at the expense of doing more IO | 53 /// shorter will give more immediate feedback at the expense of doing more IO |
53 /// and higher CPU usage. Defaults to one second. Ignored for non-polling | 54 /// and higher CPU usage. Defaults to one second. Ignored for non-polling |
54 /// watchers. | 55 /// watchers. |
55 factory DirectoryWatcher(String directory, {Duration pollingDelay}) { | 56 factory DirectoryWatcher(String directory, {Duration pollingDelay}) { |
56 if (Platform.isLinux) return new LinuxDirectoryWatcher(directory); | 57 if (Platform.isLinux) return new LinuxDirectoryWatcher(directory); |
| 58 if (Platform.isMacOS) return new MacOSDirectoryWatcher(directory); |
57 return new PollingDirectoryWatcher(directory, pollingDelay: pollingDelay); | 59 return new PollingDirectoryWatcher(directory, pollingDelay: pollingDelay); |
58 } | 60 } |
59 } | 61 } |
OLD | NEW |