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'; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 /// | 48 /// |
49 /// If a native directory watcher is available for this platform, this will | 49 /// If a native directory watcher is available for this platform, this will |
50 /// use it. Otherwise, it will fall back to a [PollingDirectoryWatcher]. | 50 /// use it. Otherwise, it will fall back to a [PollingDirectoryWatcher]. |
51 /// | 51 /// |
52 /// If [_pollingDelay] is passed, it specifies the amount of time the watcher | 52 /// If [_pollingDelay] is passed, it specifies the amount of time the watcher |
53 /// will pause between successive polls of the directory contents. Making this | 53 /// will pause between successive polls of the directory contents. Making this |
54 /// shorter will give more immediate feedback at the expense of doing more IO | 54 /// shorter will give more immediate feedback at the expense of doing more IO |
55 /// and higher CPU usage. Defaults to one second. Ignored for non-polling | 55 /// and higher CPU usage. Defaults to one second. Ignored for non-polling |
56 /// watchers. | 56 /// watchers. |
57 factory DirectoryWatcher(String directory, {Duration pollingDelay}) { | 57 factory DirectoryWatcher(String directory, {Duration pollingDelay}) { |
58 if (Platform.isLinux) return new LinuxDirectoryWatcher(directory); | 58 if (FileSystemEntity.isWatchSupported) { |
59 if (Platform.isMacOS) return new MacOSDirectoryWatcher(directory); | 59 if (Platform.isLinux) return new LinuxDirectoryWatcher(directory); |
60 if (Platform.isWindows) return new WindowsDirectoryWatcher(directory); | 60 if (Platform.isMacOS) return new MacOSDirectoryWatcher(directory); |
| 61 if (Platform.isWindows) return new WindowsDirectoryWatcher(directory); |
| 62 } |
61 return new PollingDirectoryWatcher(directory, pollingDelay: pollingDelay); | 63 return new PollingDirectoryWatcher(directory, pollingDelay: pollingDelay); |
62 } | 64 } |
63 } | 65 } |
OLD | NEW |