| 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.linux; | 5 library watcher.directory_watcher.linux; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import '../directory_watcher.dart'; | 10 import '../directory_watcher.dart'; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 }, onDone: () { | 75 }, onDone: () { |
| 76 _waitUntilReady().then((_) => _readyCompleter.complete()); | 76 _waitUntilReady().then((_) => _readyCompleter.complete()); |
| 77 }, cancelOnError: true); | 77 }, cancelOnError: true); |
| 78 } | 78 } |
| 79 | 79 |
| 80 /// Returns a [Future] that completes once all the subdirectory watchers are | 80 /// Returns a [Future] that completes once all the subdirectory watchers are |
| 81 /// fully initialized. | 81 /// fully initialized. |
| 82 Future _waitUntilReady() { | 82 Future _waitUntilReady() { |
| 83 return Future.wait(_subWatchers.values.map((watcher) => watcher.ready)) | 83 return Future.wait(_subWatchers.values.map((watcher) => watcher.ready)) |
| 84 .then((_) { | 84 .then((_) { |
| 85 if (_subWatchers.values.every((watcher) => watcher.isReady)) return; | 85 if (_subWatchers.values.every((watcher) => watcher.isReady)) return null; |
| 86 return _waitUntilReady(); | 86 return _waitUntilReady(); |
| 87 }); | 87 }); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void close() { | 90 void close() { |
| 91 for (var subscription in _subscriptions) { | 91 for (var subscription in _subscriptions) { |
| 92 subscription.cancel(); | 92 subscription.cancel(); |
| 93 } | 93 } |
| 94 for (var watcher in _subWatchers.values) { | 94 for (var watcher in _subWatchers.values) { |
| 95 watcher.close(); | 95 watcher.close(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 static const DIRECTORY = const _EntryState._("directory"); | 289 static const DIRECTORY = const _EntryState._("directory"); |
| 290 | 290 |
| 291 const _EntryState._(this._name); | 291 const _EntryState._(this._name); |
| 292 | 292 |
| 293 /// Returns [DIRECTORY] if [isDir] is true, and [FILE] otherwise. | 293 /// Returns [DIRECTORY] if [isDir] is true, and [FILE] otherwise. |
| 294 factory _EntryState(bool isDir) => | 294 factory _EntryState(bool isDir) => |
| 295 isDir ? _EntryState.DIRECTORY : _EntryState.FILE; | 295 isDir ? _EntryState.DIRECTORY : _EntryState.FILE; |
| 296 | 296 |
| 297 String toString() => _name; | 297 String toString() => _name; |
| 298 } | 298 } |
| OLD | NEW |