Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: sdk/lib/io/directory_impl.dart

Issue 1974043002: Revert "Fix remaining strong-mode warnings and errors in dart:io." (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/data_transformer.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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])
« no previous file with comments | « sdk/lib/io/data_transformer.dart ('k') | sdk/lib/io/file_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698