| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 return opened.close().transform((ignore) => file); | 122 return opened.close().transform((ignore) => file); |
| 123 }); | 123 }); |
| 124 }); | 124 }); |
| 125 } | 125 } |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * Asynchronously deletes [file], which can be a [String] or a [File]. Returns a | 128 * Asynchronously deletes [file], which can be a [String] or a [File]. Returns a |
| 129 * [Future] that completes when the deletion is done. | 129 * [Future] that completes when the deletion is done. |
| 130 */ | 130 */ |
| 131 Future<Directory> deleteFile(file) { | 131 Future<Directory> deleteFile(file) { |
| 132 return new File(_getPath(file)).delete(); | 132 file = _getFile(file); |
| 133 return file.delete(); |
| 133 } | 134 } |
| 134 | 135 |
| 135 /** | 136 /** |
| 136 * Creates a directory [dir]. Returns a [Future] that completes when the | 137 * Creates a directory [dir]. Returns a [Future] that completes when the |
| 137 * directory is created. | 138 * directory is created. |
| 138 */ | 139 */ |
| 139 Future<Directory> createDir(dir) { | 140 Future<Directory> createDir(dir) { |
| 140 dir = _getDirectory(dir); | 141 dir = _getDirectory(dir); |
| 141 return dir.create(); | 142 return dir.create(); |
| 142 } | 143 } |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 return new Directory(entry); | 471 return new Directory(entry); |
| 471 } | 472 } |
| 472 | 473 |
| 473 /** | 474 /** |
| 474 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. | 475 * Gets a [Uri] for [uri], which can either already be one, or be a [String]. |
| 475 */ | 476 */ |
| 476 Uri _getUri(uri) { | 477 Uri _getUri(uri) { |
| 477 if (uri is Uri) return uri; | 478 if (uri is Uri) return uri; |
| 478 return new Uri.fromString(uri); | 479 return new Uri.fromString(uri); |
| 479 } | 480 } |
| OLD | NEW |