Chromium Code Reviews| 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..d3c6a1406ecb24b64cf4f0990d258d8a6a676c13 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; |
| } |
| @@ -85,6 +88,8 @@ class _Directory implements Directory { |
| path = path.directoryPath; |
| } |
| return _computeExistingIndex(dirsToCreate).chain((index) { |
| + // If none of the directories already exist we need to create them all. |
| + if (index == -1) index = dirsToCreate.length; |
|
Søren Gjesse
2013/01/03 15:11:13
I can't figure out how the _computeExistingIndex c
Mads Ager (google)
2013/01/03 16:04:16
D'oh! That was what it used to do, so this was my
|
| var future; |
| for (var i = index - 1; i >= 0 ; i--) { |
| if (future == null) { |