| 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 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 if ((buffer is !List && buffer is !ByteData) || | 776 if ((buffer is !List && buffer is !ByteData) || |
| 777 (start != null && start is !int) || | 777 (start != null && start is !int) || |
| 778 (end != null && end is !int)) { | 778 (end != null && end is !int)) { |
| 779 throw new ArgumentError("Invalid arguments to writeFrom"); | 779 throw new ArgumentError("Invalid arguments to writeFrom"); |
| 780 } | 780 } |
| 781 | 781 |
| 782 if (closed) return _closedException(); | 782 if (closed) return _closedException(); |
| 783 | 783 |
| 784 _BufferAndStart result; | 784 _BufferAndStart result; |
| 785 try { | 785 try { |
| 786 result = _ensureFastAndSerializableData(buffer, start, end); | 786 result = _ensureFastAndSerializableByteData(buffer, start, end); |
| 787 } catch (e) { | 787 } catch (e) { |
| 788 return new Future.error(e); | 788 return new Future.error(e); |
| 789 } | 789 } |
| 790 | 790 |
| 791 List request = new List(5); | 791 List request = new List(5); |
| 792 request[0] = _WRITE_LIST_REQUEST; | 792 request[0] = _WRITE_LIST_REQUEST; |
| 793 request[1] = _id; | 793 request[1] = _id; |
| 794 request[2] = result.buffer; | 794 request[2] = result.buffer; |
| 795 request[3] = result.start; | 795 request[3] = result.start; |
| 796 request[4] = end - (start - result.start); | 796 request[4] = end - (start - result.start); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 809 if (buffer is !List || | 809 if (buffer is !List || |
| 810 (start != null && start is !int) || | 810 (start != null && start is !int) || |
| 811 (end != null && end is !int)) { | 811 (end != null && end is !int)) { |
| 812 throw new ArgumentError("Invalid arguments to writeFromSync"); | 812 throw new ArgumentError("Invalid arguments to writeFromSync"); |
| 813 } | 813 } |
| 814 if (start == null) start = 0; | 814 if (start == null) start = 0; |
| 815 if (end == null) end = buffer.length; | 815 if (end == null) end = buffer.length; |
| 816 if (end == start) return; | 816 if (end == start) return; |
| 817 _checkReadWriteListArguments(buffer.length, start, end); | 817 _checkReadWriteListArguments(buffer.length, start, end); |
| 818 _BufferAndStart bufferAndStart = | 818 _BufferAndStart bufferAndStart = |
| 819 _ensureFastAndSerializableData(buffer, start, end); | 819 _ensureFastAndSerializableByteData(buffer, start, end); |
| 820 var result = _writeFrom(_id, | 820 var result = _writeFrom(_id, |
| 821 bufferAndStart.buffer, | 821 bufferAndStart.buffer, |
| 822 bufferAndStart.start, | 822 bufferAndStart.start, |
| 823 end - (start - bufferAndStart.start)); | 823 end - (start - bufferAndStart.start)); |
| 824 if (result is OSError) { | 824 if (result is OSError) { |
| 825 throw new FileException("writeFrom failed", _path, result); | 825 throw new FileException("writeFrom failed", _path, result); |
| 826 } | 826 } |
| 827 } | 827 } |
| 828 | 828 |
| 829 Future<RandomAccessFile> writeString(String string, | 829 Future<RandomAccessFile> writeString(String string, |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 987 | 987 |
| 988 Future _closedException() { | 988 Future _closedException() { |
| 989 return new Future.error(new FileException("File closed", _path)); | 989 return new Future.error(new FileException("File closed", _path)); |
| 990 } | 990 } |
| 991 | 991 |
| 992 final String _path; | 992 final String _path; |
| 993 int _id; | 993 int _id; |
| 994 | 994 |
| 995 SendPort _fileService; | 995 SendPort _fileService; |
| 996 } | 996 } |
| OLD | NEW |