| 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 class _FileInputStream extends _BaseDataInputStream implements InputStream { | 5 class _FileInputStream extends _BaseDataInputStream implements InputStream { |
| 6 _FileInputStream(String name) | 6 _FileInputStream(String name) |
| 7 : _data = const [], | 7 : _data = const [], |
| 8 _position = 0, | 8 _position = 0, |
| 9 _filePosition = 0 { | 9 _filePosition = 0 { |
| 10 var file = new File(name); | 10 var file = new File(name); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } else { | 191 } else { |
| 192 _write(data, 0, data.length); | 192 _write(data, 0, data.length); |
| 193 } | 193 } |
| 194 return false; | 194 return false; |
| 195 } | 195 } |
| 196 | 196 |
| 197 bool writeFrom(List<int> buffer, [int offset = 0, int len]) { | 197 bool writeFrom(List<int> buffer, [int offset = 0, int len]) { |
| 198 // A copy is required by the interface. | 198 // A copy is required by the interface. |
| 199 var length = buffer.length - offset; | 199 var length = buffer.length - offset; |
| 200 if (len != null) { | 200 if (len != null) { |
| 201 if (len > length) throw new IndexOutOfRangeException(len); | 201 if (len > length) throw new RangeError(len); |
| 202 length = len; | 202 length = len; |
| 203 } | 203 } |
| 204 var copy = new Uint8List(length); | 204 var copy = new Uint8List(length); |
| 205 copy.setRange(0, length, buffer, offset); | 205 copy.setRange(0, length, buffer, offset); |
| 206 return write(copy); | 206 return write(copy); |
| 207 } | 207 } |
| 208 | 208 |
| 209 | 209 |
| 210 void flush() { | 210 void flush() { |
| 211 if (_file == null) { | 211 if (_file == null) { |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 "readList failed for file '$_name'"); | 762 "readList failed for file '$_name'"); |
| 763 } | 763 } |
| 764 var read = response[1]; | 764 var read = response[1]; |
| 765 var data = response[2]; | 765 var data = response[2]; |
| 766 buffer.setRange(offset, read, data); | 766 buffer.setRange(offset, read, data); |
| 767 return read; | 767 return read; |
| 768 }); | 768 }); |
| 769 } | 769 } |
| 770 | 770 |
| 771 static void _checkReadWriteListArguments(int length, int offset, int bytes) { | 771 static void _checkReadWriteListArguments(int length, int offset, int bytes) { |
| 772 if (offset < 0) throw new IndexOutOfRangeException(offset); | 772 if (offset < 0) throw new RangeError(offset); |
| 773 if (bytes < 0) throw new IndexOutOfRangeException(bytes); | 773 if (bytes < 0) throw new RangeError(bytes); |
| 774 if ((offset + bytes) > length) { | 774 if ((offset + bytes) > length) { |
| 775 throw new IndexOutOfRangeException(offset + bytes); | 775 throw new RangeError(offset + bytes); |
| 776 } | 776 } |
| 777 } | 777 } |
| 778 | 778 |
| 779 static _readList(int id, List<int> buffer, int offset, int bytes) | 779 static _readList(int id, List<int> buffer, int offset, int bytes) |
| 780 native "File_ReadList"; | 780 native "File_ReadList"; |
| 781 | 781 |
| 782 int readListSync(List<int> buffer, int offset, int bytes) { | 782 int readListSync(List<int> buffer, int offset, int bytes) { |
| 783 _checkNotClosed(); | 783 _checkNotClosed(); |
| 784 if (buffer is !List || offset is !int || bytes is !int) { | 784 if (buffer is !List || offset is !int || bytes is !int) { |
| 785 throw new FileIOException( | 785 throw new FileIOException( |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 new FileIOException("File closed '$_name'")); | 1086 new FileIOException("File closed '$_name'")); |
| 1087 }); | 1087 }); |
| 1088 return completer.future; | 1088 return completer.future; |
| 1089 } | 1089 } |
| 1090 | 1090 |
| 1091 final String _name; | 1091 final String _name; |
| 1092 int _id; | 1092 int _id; |
| 1093 | 1093 |
| 1094 SendPort _fileService; | 1094 SendPort _fileService; |
| 1095 } | 1095 } |
| OLD | NEW |