| 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 'package:stack_trace/stack_trace.dart'; | 10 import 'package:stack_trace/stack_trace.dart'; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 var watcher = new _LinuxDirectoryWatcher(path); | 127 var watcher = new _LinuxDirectoryWatcher(path); |
| 128 _subWatchers[path] = watcher; | 128 _subWatchers[path] = watcher; |
| 129 | 129 |
| 130 // TODO(nweiz): Catch any errors here that indicate that the directory in | 130 // TODO(nweiz): Catch any errors here that indicate that the directory in |
| 131 // question doesn't exist and silently stop watching it instead of | 131 // question doesn't exist and silently stop watching it instead of |
| 132 // propagating the errors. | 132 // propagating the errors. |
| 133 _listen(watcher.events, (event) { | 133 _listen(watcher.events, (event) { |
| 134 if (isReady) _eventsController.add(event); | 134 if (isReady) _eventsController.add(event); |
| 135 }, onError: (error, stackTrace) { | 135 }, onError: (error, stackTrace) { |
| 136 _eventsController.addError(error, stackTrace); | 136 _eventsController.addError(error, stackTrace); |
| 137 _eventsController.close(); | 137 close(); |
| 138 }, onDone: () { | 138 }, onDone: () { |
| 139 if (_subWatchers[path] == watcher) _subWatchers.remove(path); | 139 if (_subWatchers[path] == watcher) _subWatchers.remove(path); |
| 140 | 140 |
| 141 // It's possible that a directory was removed and recreated very quickly. | 141 // It's possible that a directory was removed and recreated very quickly. |
| 142 // If so, make sure we're still watching it. | 142 // If so, make sure we're still watching it. |
| 143 if (new Directory(path).existsSync()) _watchSubdir(path); | 143 if (new Directory(path).existsSync()) _watchSubdir(path); |
| 144 }); | 144 }); |
| 145 | 145 |
| 146 // TODO(nweiz): Right now it's possible for the watcher to emit an event for | 146 // TODO(nweiz): Right now it's possible for the watcher to emit an event for |
| 147 // a file before the directory list is complete. This could lead to the user | 147 // a file before the directory list is complete. This could lead to the user |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 static const DIRECTORY = const _EntryState._("directory"); | 299 static const DIRECTORY = const _EntryState._("directory"); |
| 300 | 300 |
| 301 const _EntryState._(this._name); | 301 const _EntryState._(this._name); |
| 302 | 302 |
| 303 /// Returns [DIRECTORY] if [isDir] is true, and [FILE] otherwise. | 303 /// Returns [DIRECTORY] if [isDir] is true, and [FILE] otherwise. |
| 304 factory _EntryState(bool isDir) => | 304 factory _EntryState(bool isDir) => |
| 305 isDir ? _EntryState.DIRECTORY : _EntryState.FILE; | 305 isDir ? _EntryState.DIRECTORY : _EntryState.FILE; |
| 306 | 306 |
| 307 String toString() => _name; | 307 String toString() => _name; |
| 308 } | 308 } |
| OLD | NEW |