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 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 var read = response[1]; | 706 var read = response[1]; |
707 var data = response[2]; | 707 var data = response[2]; |
708 buffer.setRange(start, start + read, data); | 708 buffer.setRange(start, start + read, data); |
709 _readCount++; | 709 _readCount++; |
710 _totalRead += read; | 710 _totalRead += read; |
711 return read; | 711 return read; |
712 }); | 712 }); |
713 } | 713 } |
714 | 714 |
715 static void _checkReadWriteListArguments(int length, int start, int end) { | 715 static void _checkReadWriteListArguments(int length, int start, int end) { |
716 if (start < 0) throw new RangeError.value(start); | 716 RangeError.checkValidRange(start, end, length); |
717 if (end < start) throw new RangeError.value(end); | |
718 if (end > length) { | |
719 throw new RangeError.value(end); | |
720 } | |
721 } | 717 } |
722 | 718 |
723 external static _readInto(int id, List<int> buffer, int start, int end); | 719 external static _readInto(int id, List<int> buffer, int start, int end); |
724 | 720 |
725 int readIntoSync(List<int> buffer, [int start, int end]) { | 721 int readIntoSync(List<int> buffer, [int start, int end]) { |
726 _checkAvailable(); | 722 _checkAvailable(); |
727 if (buffer is !List || | 723 if (buffer is !List || |
728 (start != null && start is !int) || | 724 (start != null && start is !int) || |
729 (end != null && end is !int)) { | 725 (end != null && end is !int)) { |
730 throw new ArgumentError(); | 726 throw new ArgumentError(); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 void _checkAvailable() { | 965 void _checkAvailable() { |
970 if (_asyncDispatched) { | 966 if (_asyncDispatched) { |
971 throw new FileSystemException("An async operation is currently pending", | 967 throw new FileSystemException("An async operation is currently pending", |
972 path); | 968 path); |
973 } | 969 } |
974 if (closed) { | 970 if (closed) { |
975 throw new FileSystemException("File closed", path); | 971 throw new FileSystemException("File closed", path); |
976 } | 972 } |
977 } | 973 } |
978 } | 974 } |
OLD | NEW |