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