| 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 // Read the file in blocks of size 64k. | 7 // Read the file in blocks of size 64k. |
| 8 const int _BLOCK_SIZE = 64 * 1024; | 8 const int _BLOCK_SIZE = 64 * 1024; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 List<String> readAsLinesSync({Encoding encoding: Encoding.UTF_8}) { | 527 List<String> readAsLinesSync({Encoding encoding: Encoding.UTF_8}) { |
| 528 return _decodeLines(readAsBytesSync(), encoding); | 528 return _decodeLines(readAsBytesSync(), encoding); |
| 529 } | 529 } |
| 530 | 530 |
| 531 Future<File> writeAsBytes(List<int> bytes, | 531 Future<File> writeAsBytes(List<int> bytes, |
| 532 {FileMode mode: FileMode.WRITE}) { | 532 {FileMode mode: FileMode.WRITE}) { |
| 533 try { | 533 try { |
| 534 IOSink sink = openWrite(mode: mode); | 534 IOSink sink = openWrite(mode: mode); |
| 535 sink.add(bytes); | 535 sink.add(bytes); |
| 536 sink.close(); | 536 sink.close(); |
| 537 return sink.done.then((_) => this);; | 537 return sink.done.then((_) => this); |
| 538 } catch (e) { | 538 } catch (e) { |
| 539 return new Future.error(e); | 539 return new Future.error(e); |
| 540 } | 540 } |
| 541 } | 541 } |
| 542 | 542 |
| 543 void writeAsBytesSync(List<int> bytes, {FileMode mode: FileMode.WRITE}) { | 543 void writeAsBytesSync(List<int> bytes, {FileMode mode: FileMode.WRITE}) { |
| 544 RandomAccessFile opened = openSync(mode: mode); | 544 RandomAccessFile opened = openSync(mode: mode); |
| 545 opened.writeFromSync(bytes, 0, bytes.length); | 545 opened.writeFromSync(bytes, 0, bytes.length); |
| 546 opened.closeSync(); | 546 opened.closeSync(); |
| 547 } | 547 } |
| (...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 996 | 996 |
| 997 Future _closedException() { | 997 Future _closedException() { |
| 998 return new Future.error(new FileIOException("File closed '$_path'")); | 998 return new Future.error(new FileIOException("File closed '$_path'")); |
| 999 } | 999 } |
| 1000 | 1000 |
| 1001 final String _path; | 1001 final String _path; |
| 1002 int _id; | 1002 int _id; |
| 1003 | 1003 |
| 1004 SendPort _fileService; | 1004 SendPort _fileService; |
| 1005 } | 1005 } |
| OLD | NEW |