| 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 '../utils.dart'; | 10 import '../utils.dart'; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 if (!isReady || _eventsController.isClosed) return; | 159 if (!isReady || _eventsController.isClosed) return; |
| 160 _listen(new Directory(path).list(recursive: true), (entry) { | 160 _listen(new Directory(path).list(recursive: true), (entry) { |
| 161 if (entry is Directory) return; | 161 if (entry is Directory) return; |
| 162 _eventsController.add(new WatchEvent(ChangeType.ADD, entry.path)); | 162 _eventsController.add(new WatchEvent(ChangeType.ADD, entry.path)); |
| 163 }, onError: (error, stackTrace) { | 163 }, onError: (error, stackTrace) { |
| 164 // Ignore an exception caused by the dir not existing. It's fine if it | 164 // Ignore an exception caused by the dir not existing. It's fine if it |
| 165 // was added and then quickly removed. | 165 // was added and then quickly removed. |
| 166 if (error is FileSystemException) return; | 166 if (error is FileSystemException) return; |
| 167 | 167 |
| 168 _eventsController.addError(error, stackTrace); | 168 _eventsController.addError(error, stackTrace); |
| 169 _eventsController.close(); | 169 close(); |
| 170 }, cancelOnError: true); | 170 }, cancelOnError: true); |
| 171 }); | 171 }); |
| 172 } | 172 } |
| 173 | 173 |
| 174 /// The callback that's run when a batch of changes comes in. | 174 /// The callback that's run when a batch of changes comes in. |
| 175 void _onBatch(List<FileSystemEvent> batch) { | 175 void _onBatch(List<FileSystemEvent> batch) { |
| 176 var changedEntries = new Set<String>(); | 176 var changedEntries = new Set<String>(); |
| 177 var oldEntries = new Map.from(_entries); | 177 var oldEntries = new Map.from(_entries); |
| 178 | 178 |
| 179 // inotify event batches are ordered by occurrence, so we treat them as a | 179 // inotify event batches are ordered by occurrence, so we treat them as a |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 static const DIRECTORY = const _EntryState._("directory"); | 286 static const DIRECTORY = const _EntryState._("directory"); |
| 287 | 287 |
| 288 const _EntryState._(this._name); | 288 const _EntryState._(this._name); |
| 289 | 289 |
| 290 /// Returns [DIRECTORY] if [isDir] is true, and [FILE] otherwise. | 290 /// Returns [DIRECTORY] if [isDir] is true, and [FILE] otherwise. |
| 291 factory _EntryState(bool isDir) => | 291 factory _EntryState(bool isDir) => |
| 292 isDir ? _EntryState.DIRECTORY : _EntryState.FILE; | 292 isDir ? _EntryState.DIRECTORY : _EntryState.FILE; |
| 293 | 293 |
| 294 String toString() => _name; | 294 String toString() => _name; |
| 295 } | 295 } |
| OLD | NEW |