| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * FileMode describes the modes in which a file can be opened. | 8 * FileMode describes the modes in which a file can be opened. |
| 9 */ | 9 */ |
| 10 class FileMode { | 10 class FileMode { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 * | 128 * |
| 129 * [FileMode.READ]: open the file for reading. | 129 * [FileMode.READ]: open the file for reading. |
| 130 * | 130 * |
| 131 * [FileMode.WRITE]: open the file for both reading and writing and | 131 * [FileMode.WRITE]: open the file for both reading and writing and |
| 132 * truncate the file to length zero. If the file does not exist the | 132 * truncate the file to length zero. If the file does not exist the |
| 133 * file is created. | 133 * file is created. |
| 134 * | 134 * |
| 135 * [FileMode.APPEND]: same as [FileMode.WRITE] except that the file is | 135 * [FileMode.APPEND]: same as [FileMode.WRITE] except that the file is |
| 136 * not truncated. | 136 * not truncated. |
| 137 */ | 137 */ |
| 138 Future<RandomAccessFile> open([FileMode mode = FileMode.READ]); | 138 Future<RandomAccessFile> open({FileMode mode: FileMode.READ}); |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * Synchronously open the file for random access operations. The | 141 * Synchronously open the file for random access operations. The |
| 142 * result is a [RandomAccessFile] on which random access operations | 142 * result is a [RandomAccessFile] on which random access operations |
| 143 * can be performed. Opened [RandomAccessFile]s must be closed using | 143 * can be performed. Opened [RandomAccessFile]s must be closed using |
| 144 * the [RandomAccessFile.close] method. | 144 * the [RandomAccessFile.close] method. |
| 145 * | 145 * |
| 146 * See [open] for information on the [mode] argument. | 146 * See [open] for information on the [mode] argument. |
| 147 */ | 147 */ |
| 148 RandomAccessFile openSync([FileMode mode = FileMode.READ]); | 148 RandomAccessFile openSync({FileMode mode: FileMode.READ}); |
| 149 | 149 |
| 150 /** | 150 /** |
| 151 * Get the canonical full path corresponding to the file path. | 151 * Get the canonical full path corresponding to the file path. |
| 152 * Returns a [:Future<String>:] that completes with the path. | 152 * Returns a [:Future<String>:] that completes with the path. |
| 153 */ | 153 */ |
| 154 Future<String> fullPath(); | 154 Future<String> fullPath(); |
| 155 | 155 |
| 156 /** | 156 /** |
| 157 * Synchronously get the canonical full path corresponding to the file path. | 157 * Synchronously get the canonical full path corresponding to the file path. |
| 158 */ | 158 */ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 */ | 200 */ |
| 201 List<int> readAsBytesSync(); | 201 List<int> readAsBytesSync(); |
| 202 | 202 |
| 203 /** | 203 /** |
| 204 * Read the entire file contents as a string using the given | 204 * Read the entire file contents as a string using the given |
| 205 * [Encoding]. | 205 * [Encoding]. |
| 206 * | 206 * |
| 207 * Returns a [:Future<String>:] that completes with the string once | 207 * Returns a [:Future<String>:] that completes with the string once |
| 208 * the file contents has been read. | 208 * the file contents has been read. |
| 209 */ | 209 */ |
| 210 Future<String> readAsString([Encoding encoding = Encoding.UTF_8]); | 210 Future<String> readAsString({Encoding encoding: Encoding.UTF_8}); |
| 211 | 211 |
| 212 /** | 212 /** |
| 213 * Synchronously read the entire file contents as a string using the | 213 * Synchronously read the entire file contents as a string using the |
| 214 * given [Encoding]. | 214 * given [Encoding]. |
| 215 */ | 215 */ |
| 216 String readAsStringSync([Encoding encoding = Encoding.UTF_8]); | 216 String readAsStringSync({Encoding encoding: Encoding.UTF_8}); |
| 217 | 217 |
| 218 /** | 218 /** |
| 219 * Read the entire file contents as lines of text using the given | 219 * Read the entire file contents as lines of text using the given |
| 220 * [Encoding]. | 220 * [Encoding]. |
| 221 * | 221 * |
| 222 * Returns a [:Future<List<String>>:] that completes with the lines | 222 * Returns a [:Future<List<String>>:] that completes with the lines |
| 223 * once the file contents has been read. | 223 * once the file contents has been read. |
| 224 */ | 224 */ |
| 225 Future<List<String>> readAsLines([Encoding encoding = Encoding.UTF_8]); | 225 Future<List<String>> readAsLines({Encoding encoding: Encoding.UTF_8}); |
| 226 | 226 |
| 227 /** | 227 /** |
| 228 * Synchronously read the entire file contents as lines of text | 228 * Synchronously read the entire file contents as lines of text |
| 229 * using the given [Encoding]. | 229 * using the given [Encoding]. |
| 230 */ | 230 */ |
| 231 List<String> readAsLinesSync([Encoding encoding = Encoding.UTF_8]); | 231 List<String> readAsLinesSync({Encoding encoding: Encoding.UTF_8}); |
| 232 | 232 |
| 233 /** | 233 /** |
| 234 * Write a list of bytes to a file. | 234 * Write a list of bytes to a file. |
| 235 * | 235 * |
| 236 * Opens the file, writes the list of bytes to it, and closes the file. | 236 * Opens the file, writes the list of bytes to it, and closes the file. |
| 237 * Returns a [:Future<File>:] that completes with this [File] object once | 237 * Returns a [:Future<File>:] that completes with this [File] object once |
| 238 * the entire operation has completed. | 238 * the entire operation has completed. |
| 239 * | 239 * |
| 240 * By default [writeAsBytes] creates the file for writing and truncates the | 240 * By default [writeAsBytes] creates the file for writing and truncates the |
| 241 * file if it already exists. In order to append the bytes to an existing | 241 * file if it already exists. In order to append the bytes to an existing |
| 242 * file, pass [FileMode.APPEND] as the optional mode parameter. | 242 * file, pass [FileMode.APPEND] as the optional mode parameter. |
| 243 */ | 243 */ |
| 244 Future<File> writeAsBytes(List<int> bytes, [FileMode mode = FileMode.WRITE]); | 244 Future<File> writeAsBytes(List<int> bytes, {FileMode mode: FileMode.WRITE}); |
| 245 | 245 |
| 246 /** | 246 /** |
| 247 * Synchronously write a list of bytes to a file. | 247 * Synchronously write a list of bytes to a file. |
| 248 * | 248 * |
| 249 * Opens the file, writes the list of bytes to it and closes the file. | 249 * Opens the file, writes the list of bytes to it and closes the file. |
| 250 * | 250 * |
| 251 * By default [writeAsBytesSync] creates the file for writing and truncates | 251 * By default [writeAsBytesSync] creates the file for writing and truncates |
| 252 * the file if it already exists. In order to append the bytes to an existing | 252 * the file if it already exists. In order to append the bytes to an existing |
| 253 * file, pass [FileMode.APPEND] as the optional mode parameter. | 253 * file, pass [FileMode.APPEND] as the optional mode parameter. |
| 254 */ | 254 */ |
| 255 void writeAsBytesSync(List<int> bytes, [FileMode mode = FileMode.WRITE]); | 255 void writeAsBytesSync(List<int> bytes, {FileMode mode: FileMode.WRITE}); |
| 256 | 256 |
| 257 /** | 257 /** |
| 258 * Write a string to a file. | 258 * Write a string to a file. |
| 259 * | 259 * |
| 260 * Opens the file, writes the string in the given encoding, and closes the | 260 * Opens the file, writes the string in the given encoding, and closes the |
| 261 * file. Returns a [:Future<File>:] that completes with this [File] object | 261 * file. Returns a [:Future<File>:] that completes with this [File] object |
| 262 * once the entire operation has completed. | 262 * once the entire operation has completed. |
| 263 * | 263 * |
| 264 * By default [writeAsString] creates the file for writing and truncates the | 264 * By default [writeAsString] creates the file for writing and truncates the |
| 265 * file if it already exists. In order to append the bytes to an existing | 265 * file if it already exists. In order to append the bytes to an existing |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 * of bytes successfully written. | 374 * of bytes successfully written. |
| 375 */ | 375 */ |
| 376 int writeListSync(List<int> buffer, int offset, int bytes); | 376 int writeListSync(List<int> buffer, int offset, int bytes); |
| 377 | 377 |
| 378 /** | 378 /** |
| 379 * Writes a string to the file using the given [Encoding]. Returns a | 379 * Writes a string to the file using the given [Encoding]. Returns a |
| 380 * [:Future<RandomAccessFile>:] that completes with this | 380 * [:Future<RandomAccessFile>:] that completes with this |
| 381 * RandomAccessFile when the write completes. | 381 * RandomAccessFile when the write completes. |
| 382 */ | 382 */ |
| 383 Future<RandomAccessFile> writeString(String string, | 383 Future<RandomAccessFile> writeString(String string, |
| 384 [Encoding encoding = Encoding.UTF_8]); | 384 {Encoding encoding: Encoding.UTF_8}); |
| 385 | 385 |
| 386 /** | 386 /** |
| 387 * Synchronously writes a single string to the file using the given | 387 * Synchronously writes a single string to the file using the given |
| 388 * [Encoding]. Returns the number of characters successfully | 388 * [Encoding]. Returns the number of characters successfully |
| 389 * written. | 389 * written. |
| 390 */ | 390 */ |
| 391 int writeStringSync(String string, | 391 int writeStringSync(String string, |
| 392 [Encoding encoding = Encoding.UTF_8]); | 392 {Encoding encoding: Encoding.UTF_8}); |
| 393 | 393 |
| 394 /** | 394 /** |
| 395 * Gets the current byte position in the file. Returns a | 395 * Gets the current byte position in the file. Returns a |
| 396 * [:Future<int>:] that completes with the position. | 396 * [:Future<int>:] that completes with the position. |
| 397 */ | 397 */ |
| 398 Future<int> position(); | 398 Future<int> position(); |
| 399 | 399 |
| 400 /** | 400 /** |
| 401 * Synchronously gets the current byte position in the file. | 401 * Synchronously gets the current byte position in the file. |
| 402 */ | 402 */ |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 sb.write(" ($osError)"); | 473 sb.write(" ($osError)"); |
| 474 } | 474 } |
| 475 } else if (osError != null) { | 475 } else if (osError != null) { |
| 476 sb.write(": osError"); | 476 sb.write(": osError"); |
| 477 } | 477 } |
| 478 return sb.toString(); | 478 return sb.toString(); |
| 479 } | 479 } |
| 480 final String message; | 480 final String message; |
| 481 final OSError osError; | 481 final OSError osError; |
| 482 } | 482 } |
| OLD | NEW |