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

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

Issue 11759007: Fix Directory.create(recursive: true) for non-existing paths. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 12 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 | « no previous file | tests/standalone/io/regress_7679_test.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 d96151f329d0144cf7a9923eb543d4a712ee68dc..a3f8c281cfd0bac2b6c04523b582ac1d8350246f 100644
--- a/sdk/lib/io/directory_impl.dart
+++ b/sdk/lib/io/directory_impl.dart
@@ -52,22 +52,25 @@ class _Directory implements Directory {
return (result == 1);
}
+ // 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().transform((e) => e ? i : -1);
+ future = dirsToCreate[i].exists().transform((e) => e ? i : notFound);
} else {
future = future.chain((index) {
- if (index != -1) {
+ if (index != notFound) {
return new Future.immediate(index);
}
- return dirsToCreate[i].exists().transform((e) => e ? i : -1);
+ return dirsToCreate[i].exists().transform((e) => e ? i : notFound);
});
}
}
if (future == null) {
- return new Future.immediate(-1);
+ return new Future.immediate(notFound);
} else {
return future;
}
« no previous file with comments | « no previous file | tests/standalone/io/regress_7679_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698