Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 class _Directory extends FileSystemEntity implements Directory { | 7 class _Directory extends FileSystemEntity implements Directory { |
| 8 final String path; | 8 final String path; |
| 9 | 9 |
| 10 _Directory(String this.path) { | 10 _Directory(this.path) { |
| 11 if (path is! String) { | 11 if (path is! String) { |
| 12 throw new ArgumentError('${Error.safeToString(path)} ' | 12 throw new ArgumentError('${Error.safeToString(path)} ' |
| 13 'is not a String'); | 13 'is not a String'); |
| 14 } | 14 } |
| 15 } | 15 } |
| 16 | 16 |
| 17 external static _current(); | 17 external static _current(); |
| 18 external static _setCurrent(path); | 18 external static _setCurrent(path); |
| 19 external static _createTemp(String path); | 19 external static _createTemp(String path); |
| 20 external static String _systemTemp(); | 20 external static String _systemTemp(); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 throw new ArgumentError(); | 223 throw new ArgumentError(); |
| 224 } | 224 } |
| 225 return _list( | 225 return _list( |
| 226 FileSystemEntity._trimTrailingPathSeparators(path), | 226 FileSystemEntity._trimTrailingPathSeparators(path), |
| 227 recursive, | 227 recursive, |
| 228 followLinks); | 228 followLinks); |
| 229 } | 229 } |
| 230 | 230 |
| 231 String toString() => "Directory: '$path'"; | 231 String toString() => "Directory: '$path'"; |
| 232 | 232 |
| 233 bool _isErrorResponse(response) { | 233 bool _isErrorResponse(response) => |
|
Lasse Reichstein Nielsen
2014/01/06 09:29:30
Style guide isn't prescriptive about this - there
| |
| 234 return response is List && response[0] != _SUCCESS_RESPONSE; | 234 response is List && response[0] != _SUCCESS_RESPONSE; |
| 235 } | |
| 236 | 235 |
| 237 _exceptionOrErrorFromResponse(response, String message) { | 236 _exceptionOrErrorFromResponse(response, String message) { |
| 238 assert(_isErrorResponse(response)); | 237 assert(_isErrorResponse(response)); |
| 239 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) { | 238 switch (response[_ERROR_RESPONSE_ERROR_TYPE]) { |
| 240 case _ILLEGAL_ARGUMENT_RESPONSE: | 239 case _ILLEGAL_ARGUMENT_RESPONSE: |
| 241 return new ArgumentError(); | 240 return new ArgumentError(); |
| 242 case _OSERROR_RESPONSE: | 241 case _OSERROR_RESPONSE: |
| 243 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], | 242 var err = new OSError(response[_OSERROR_RESPONSE_MESSAGE], |
| 244 response[_OSERROR_RESPONSE_ERROR_CODE]); | 243 response[_OSERROR_RESPONSE_ERROR_CODE]); |
| 245 return new FileSystemException(message, path, err); | 244 return new FileSystemException(message, path, err); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 265 final bool recursive; | 264 final bool recursive; |
| 266 final bool followLinks; | 265 final bool followLinks; |
| 267 | 266 |
| 268 StreamController controller; | 267 StreamController controller; |
| 269 int id; | 268 int id; |
| 270 bool canceled = false; | 269 bool canceled = false; |
| 271 bool nextRunning = false; | 270 bool nextRunning = false; |
| 272 bool closed = false; | 271 bool closed = false; |
| 273 Completer closeCompleter = new Completer(); | 272 Completer closeCompleter = new Completer(); |
| 274 | 273 |
| 275 _AsyncDirectoryLister(String this.path, | 274 _AsyncDirectoryLister(this.path, this.recursive, this.followLinks) { |
| 276 bool this.recursive, | |
| 277 bool this.followLinks) { | |
| 278 controller = new StreamController(onListen: onListen, | 275 controller = new StreamController(onListen: onListen, |
| 279 onResume: onResume, | 276 onResume: onResume, |
| 280 onCancel: onCancel, | 277 onCancel: onCancel, |
| 281 sync: true); | 278 sync: true); |
| 282 } | 279 } |
| 283 | 280 |
| 284 Stream get stream => controller.stream; | 281 Stream get stream => controller.stream; |
| 285 | 282 |
| 286 void onListen() { | 283 void onListen() { |
| 287 _IOService.dispatch(_DIRECTORY_LIST_START, [path, recursive, followLinks]) | 284 _IOService.dispatch(_DIRECTORY_LIST_START, [path, recursive, followLinks]) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 controller.addError( | 377 controller.addError( |
| 381 new FileSystemException("Directory listing failed", | 378 new FileSystemException("Directory listing failed", |
| 382 errorPath, | 379 errorPath, |
| 383 err)); | 380 err)); |
| 384 } else { | 381 } else { |
| 385 controller.addError( | 382 controller.addError( |
| 386 new FileSystemException("Internal error")); | 383 new FileSystemException("Internal error")); |
| 387 } | 384 } |
| 388 } | 385 } |
| 389 } | 386 } |
| OLD | NEW |