| Index: sdk/lib/io/directory_impl.dart
|
| diff --git a/sdk/lib/io/directory_impl.dart b/sdk/lib/io/directory_impl.dart
|
| index c1fc540c52958929299e98e68f6314a51e1494b6..52cf54824ecf4e8ed14a4b5491ade076c4a32471 100644
|
| --- a/sdk/lib/io/directory_impl.dart
|
| +++ b/sdk/lib/io/directory_impl.dart
|
| @@ -72,6 +72,30 @@ class _Directory extends FileSystemEntity implements Directory {
|
|
|
| FileStat statSync() => FileStat.statSync(path);
|
|
|
| + // Compute the index of the first directory in the list that exists. If
|
| + // none of the directories exist dirsToCreate.length is returned.
|
| + Future<int> _computeExistingIndex(List dirsToCreate) {
|
| + var future;
|
| + var notFound = dirsToCreate.length;
|
| + for (var i = 0; i < dirsToCreate.length; i++) {
|
| + if (future == null) {
|
| + future = dirsToCreate[i].exists().then((e) => e ? i : notFound);
|
| + } else {
|
| + future = future.then((index) {
|
| + if (index != notFound) {
|
| + return new Future.value(index);
|
| + }
|
| + return dirsToCreate[i].exists().then((e) => e ? i : notFound);
|
| + });
|
| + }
|
| + }
|
| + if (future == null) {
|
| + return new Future.value(notFound);
|
| + } else {
|
| + return future;
|
| + }
|
| + }
|
| +
|
| Future<Directory> create({bool recursive: false}) {
|
| if (recursive) {
|
| return exists().then((exists) {
|
| @@ -256,7 +280,7 @@ class _AsyncDirectoryLister {
|
| final bool recursive;
|
| final bool followLinks;
|
|
|
| - StreamController<FileSystemEntity> controller;
|
| + StreamController controller;
|
| bool canceled = false;
|
| bool nextRunning = false;
|
| bool closed = false;
|
| @@ -264,10 +288,10 @@ class _AsyncDirectoryLister {
|
| Completer closeCompleter = new Completer();
|
|
|
| _AsyncDirectoryLister(this.path, this.recursive, this.followLinks) {
|
| - controller = new StreamController<FileSystemEntity>(onListen: onListen,
|
| - onResume: onResume,
|
| - onCancel: onCancel,
|
| - sync: true);
|
| + controller = new StreamController(onListen: onListen,
|
| + onResume: onResume,
|
| + onCancel: onCancel,
|
| + sync: true);
|
| }
|
|
|
| // Calling this function will increase the reference count on the native
|
| @@ -278,7 +302,7 @@ class _AsyncDirectoryLister {
|
| return (_ops == null) ? null : _ops.getPointer();
|
| }
|
|
|
| - Stream<FileSystemEntity> get stream => controller.stream;
|
| + Stream get stream => controller.stream;
|
|
|
| void onListen() {
|
| _IOService._dispatch(_DIRECTORY_LIST_START, [path, recursive, followLinks])
|
|
|