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 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 request[0] = _READ_LIST_REQUEST; | 733 request[0] = _READ_LIST_REQUEST; |
734 request[1] = _id; | 734 request[1] = _id; |
735 request[2] = bytes; | 735 request[2] = bytes; |
736 return _fileService.call(request).then((response) { | 736 return _fileService.call(request).then((response) { |
737 if (_isErrorResponse(response)) { | 737 if (_isErrorResponse(response)) { |
738 throw _exceptionFromResponse(response, | 738 throw _exceptionFromResponse(response, |
739 "readList failed for file '$_path'"); | 739 "readList failed for file '$_path'"); |
740 } | 740 } |
741 var read = response[1]; | 741 var read = response[1]; |
742 var data = response[2]; | 742 var data = response[2]; |
743 buffer.setRange(offset, read, data); | 743 buffer.setRange(offset, offset + read, data); |
744 return read; | 744 return read; |
745 }); | 745 }); |
746 } | 746 } |
747 | 747 |
748 static void _checkReadWriteListArguments(int length, int offset, int bytes) { | 748 static void _checkReadWriteListArguments(int length, int offset, int bytes) { |
749 if (offset < 0) throw new RangeError.value(offset); | 749 if (offset < 0) throw new RangeError.value(offset); |
750 if (bytes < 0) throw new RangeError.value(bytes); | 750 if (bytes < 0) throw new RangeError.value(bytes); |
751 if ((offset + bytes) > length) { | 751 if ((offset + bytes) > length) { |
752 throw new RangeError.value(offset + bytes); | 752 throw new RangeError.value(offset + bytes); |
753 } | 753 } |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1054 new FileIOException("File closed '$_path'")); | 1054 new FileIOException("File closed '$_path'")); |
1055 }); | 1055 }); |
1056 return completer.future; | 1056 return completer.future; |
1057 } | 1057 } |
1058 | 1058 |
1059 final String _path; | 1059 final String _path; |
1060 int _id; | 1060 int _id; |
1061 | 1061 |
1062 SendPort _fileService; | 1062 SendPort _fileService; |
1063 } | 1063 } |
OLD | NEW |