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 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 361 |
362 /** | 362 /** |
363 * Synchronously reads a maximum of [bytes] bytes from a file and | 363 * Synchronously reads a maximum of [bytes] bytes from a file and |
364 * returns the result in a list of bytes. | 364 * returns the result in a list of bytes. |
365 * | 365 * |
366 * Throws a [FileIOException] if the operation fails. | 366 * Throws a [FileIOException] if the operation fails. |
367 */ | 367 */ |
368 List<int> readSync(int bytes); | 368 List<int> readSync(int bytes); |
369 | 369 |
370 /** | 370 /** |
371 * Reads into an existing List<int> from the file. A maximum of [bytes] bytes | 371 * Reads into an existing List<int> from the file. If [start] is present, the |
372 * is read into [buffer], starting at position [offset] in the buffer. | 372 * bytes will be filled into [buffer] from at index [start], otherwise index |
| 373 * 0. If [end] is present, the [end] - [start] bytes will be read into |
| 374 * [buffer], otherwise up to [buffer.length]. If [end] == [start] nothing |
| 375 * happends. |
| 376 * |
373 * Returns a [:Future<int>:] that completes with the number of bytes read. | 377 * Returns a [:Future<int>:] that completes with the number of bytes read. |
374 */ | 378 */ |
375 Future<int> readList(List<int> buffer, int offset, int bytes); | 379 Future<int> readInto(List<int> buffer, [int start, int end]); |
376 | 380 |
377 /** | 381 /** |
378 * Synchronously reads from a file into [buffer]. A maximum of [bytes] bytes | 382 * Synchronously reads into an existing List<int> from the file. If [start] is |
379 * is read into [buffer], starting at position [offset] in the buffer. | 383 * present, the bytes will be filled into [buffer] from at index [start], |
380 * Returns the number of bytes read. | 384 * otherwise index 0. If [end] is present, the [end] - [start] bytes will be |
| 385 * read into [buffer], otherwise up to [buffer.length]. If [end] == [start] |
| 386 * nothing happends. |
381 * | 387 * |
382 * Throws a [FileIOException] if the operation fails. | 388 * Throws a [FileIOException] if the operation fails. |
383 */ | 389 */ |
384 int readListSync(List<int> buffer, int offset, int bytes); | 390 int readIntoSync(List<int> buffer, [int start, int end]); |
385 | 391 |
386 /** | 392 /** |
387 * Writes a single byte to the file. Returns a | 393 * Writes a single byte to the file. Returns a |
388 * [:Future<RandomAccessFile>:] that completes with this | 394 * [:Future<RandomAccessFile>:] that completes with this |
389 * RandomAccessFile when the write completes. | 395 * RandomAccessFile when the write completes. |
390 */ | 396 */ |
391 Future<RandomAccessFile> writeByte(int value); | 397 Future<RandomAccessFile> writeByte(int value); |
392 | 398 |
393 /** | 399 /** |
394 * Synchronously writes a single byte to the file. Returns the | 400 * Synchronously writes a single byte to the file. Returns the |
395 * number of bytes successfully written. | 401 * number of bytes successfully written. |
396 * | 402 * |
397 * Throws a [FileIOException] if the operation fails. | 403 * Throws a [FileIOException] if the operation fails. |
398 */ | 404 */ |
399 int writeByteSync(int value); | 405 int writeByteSync(int value); |
400 | 406 |
401 /** | 407 /** |
402 * Writes from a List<int> to the file. [bytes] bytes are written from | 408 * Writes from a [List<int>] to the file. It will read the buffer from index |
403 * [buffer], starting at position [offset] in the buffer. Returns a | 409 * [start] to index [end]. If [start] is omitted, it'll start from index 0. |
404 * [:Future<RandomAccessFile>:] that completes with this | 410 * If [end] is omitted, it will write to end of [buffer]. |
405 * RandomAccessFile when the write completes. | 411 * |
| 412 * Returns a [:Future<RandomAccessFile>:] that completes with this |
| 413 * [RandomAccessFile] when the write completes. |
406 */ | 414 */ |
407 Future<RandomAccessFile> writeList(List<int> buffer, int offset, int bytes); | 415 Future<RandomAccessFile> writeFrom(List<int> buffer, [int start, int end]); |
408 | 416 |
409 /** | 417 /** |
410 * Synchronously writes a List<int> to the file. [bytes] bytes are | 418 * Synchronously writes from a [List<int>] to the file. It will read the |
411 * written from [buffer], starting at position [offset] in the | 419 * buffer from index [start] to index [end]. If [start] is omitted, it'll |
412 * buffer. Returns the number of bytes successfully written. | 420 * start from index 0. If [end] is omitted, it will write to the end of |
| 421 * [buffer]. |
413 * | 422 * |
414 * Throws a [FileIOException] if the operation fails. | 423 * Throws a [FileIOException] if the operation fails. |
415 */ | 424 */ |
416 int writeListSync(List<int> buffer, int offset, int bytes); | 425 void writeFromSync(List<int> buffer, [int start, int end]); |
417 | 426 |
418 /** | 427 /** |
419 * Writes a string to the file using the given [Encoding]. Returns a | 428 * Writes a string to the file using the given [Encoding]. Returns a |
420 * [:Future<RandomAccessFile>:] that completes with this | 429 * [:Future<RandomAccessFile>:] that completes with this |
421 * RandomAccessFile when the write completes. | 430 * RandomAccessFile when the write completes. |
422 */ | 431 */ |
423 Future<RandomAccessFile> writeString(String string, | 432 Future<RandomAccessFile> writeString(String string, |
424 {Encoding encoding: Encoding.UTF_8}); | 433 {Encoding encoding: Encoding.UTF_8}); |
425 | 434 |
426 /** | 435 /** |
427 * Synchronously writes a single string to the file using the given | 436 * Synchronously writes a single string to the file using the given |
428 * [Encoding]. Returns the number of characters successfully | 437 * [Encoding]. |
429 * written. | |
430 * | 438 * |
431 * Throws a [FileIOException] if the operation fails. | 439 * Throws a [FileIOException] if the operation fails. |
432 */ | 440 */ |
433 int writeStringSync(String string, | 441 void writeStringSync(String string, |
434 {Encoding encoding: Encoding.UTF_8}); | 442 {Encoding encoding: Encoding.UTF_8}); |
435 | 443 |
436 /** | 444 /** |
437 * Gets the current byte position in the file. Returns a | 445 * Gets the current byte position in the file. Returns a |
438 * [:Future<int>:] that completes with the position. | 446 * [:Future<int>:] that completes with the position. |
439 */ | 447 */ |
440 Future<int> position(); | 448 Future<int> position(); |
441 | 449 |
442 /** | 450 /** |
443 * Synchronously gets the current byte position in the file. | 451 * Synchronously gets the current byte position in the file. |
444 * | 452 * |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 sb.write(" ($osError)"); | 533 sb.write(" ($osError)"); |
526 } | 534 } |
527 } else if (osError != null) { | 535 } else if (osError != null) { |
528 sb.write(": osError"); | 536 sb.write(": osError"); |
529 } | 537 } |
530 return sb.toString(); | 538 return sb.toString(); |
531 } | 539 } |
532 final String message; | 540 final String message; |
533 final OSError osError; | 541 final OSError osError; |
534 } | 542 } |
OLD | NEW |