| 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 /** | 5 /** |
| 6 * Helper functionality to make working with IO easier. | 6 * Helper functionality to make working with IO easier. |
| 7 */ | 7 */ |
| 8 #library('io'); | 8 #library('io'); |
| 9 | 9 |
| 10 #import('dart:io'); | 10 #import('dart:io'); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 return true; | 165 return true; |
| 166 }); | 166 }); |
| 167 future.then(completer.complete); | 167 future.then(completer.complete); |
| 168 return completer.future; | 168 return completer.future; |
| 169 }); | 169 }); |
| 170 }); | 170 }); |
| 171 } | 171 } |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * Creates a temp directory whose name will be based on [dir] with a unique | 174 * Creates a temp directory whose name will be based on [dir] with a unique |
| 175 * suffix appended to it. Returns a [Future] that completes when the directory | 175 * suffix appended to it. If [dir] is not provided, a temp directory will be |
| 176 * is created. | 176 * created in a platform-dependent temporary location. Returns a [Future] that |
| 177 * completes when the directory is created. |
| 177 */ | 178 */ |
| 178 Future<Directory> createTempDir(dir) { | 179 Future<Directory> createTempDir([dir = '']) { |
| 179 dir = _getDirectory(dir); | 180 dir = _getDirectory(dir); |
| 180 return dir.createTemp(); | 181 return dir.createTemp(); |
| 181 } | 182 } |
| 182 | 183 |
| 183 /** | 184 /** |
| 184 * Asynchronously recursively deletes [dir], which can be a [String] or a | 185 * Asynchronously recursively deletes [dir], which can be a [String] or a |
| 185 * [Directory]. Returns a [Future] that completes when the deletion is done. | 186 * [Directory]. Returns a [Future] that completes when the deletion is done. |
| 186 */ | 187 */ |
| 187 Future<Directory> deleteDir(dir) { | 188 Future<Directory> deleteDir(dir) { |
| 188 dir = _getDirectory(dir); | 189 dir = _getDirectory(dir); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 return new Directory(entry); | 484 return new Directory(entry); |
| 484 } | 485 } |
| 485 | 486 |
| 486 /** | 487 /** |
| 487 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 488 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 488 */ | 489 */ |
| 489 Uri _getUri(uri) { | 490 Uri _getUri(uri) { |
| 490 if (uri is Uri) return uri; | 491 if (uri is Uri) return uri; |
| 491 return new Uri.fromString(uri); | 492 return new Uri.fromString(uri); |
| 492 } | 493 } |
| OLD | NEW |