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 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 (start != null && start is !int) || | 763 (start != null && start is !int) || |
764 (end != null && end is !int)) { | 764 (end != null && end is !int)) { |
765 return new Future.error(new FileException( | 765 return new Future.error(new FileException( |
766 "Invalid arguments to writeFrom for file '$_path'")); | 766 "Invalid arguments to writeFrom for file '$_path'")); |
767 } | 767 } |
768 | 768 |
769 if (closed) return _closedException(); | 769 if (closed) return _closedException(); |
770 | 770 |
771 _BufferAndStart result; | 771 _BufferAndStart result; |
772 try { | 772 try { |
773 result = _ensureFastAndSerializableBuffer(buffer, start, end); | 773 result = _ensureFastAndSerializableData(buffer, start, end); |
774 } catch (e) { | 774 } catch (e) { |
775 return new Future.error(e); | 775 return new Future.error(e); |
776 } | 776 } |
777 | 777 |
778 List request = new List(5); | 778 List request = new List(5); |
779 request[0] = _WRITE_LIST_REQUEST; | 779 request[0] = _WRITE_LIST_REQUEST; |
780 request[1] = _id; | 780 request[1] = _id; |
781 request[2] = result.buffer; | 781 request[2] = result.buffer; |
782 request[3] = result.start; | 782 request[3] = result.start; |
783 request[4] = end - (start - result.start); | 783 request[4] = end - (start - result.start); |
(...skipping 14 matching lines...) Expand all Loading... |
798 (start != null && start is !int) || | 798 (start != null && start is !int) || |
799 (end != null && end is !int)) { | 799 (end != null && end is !int)) { |
800 throw new FileException( | 800 throw new FileException( |
801 "Invalid arguments to writeFrom for file '$_path'"); | 801 "Invalid arguments to writeFrom for file '$_path'"); |
802 } | 802 } |
803 if (start == null) start = 0; | 803 if (start == null) start = 0; |
804 if (end == null) end = buffer.length; | 804 if (end == null) end = buffer.length; |
805 if (end == start) return; | 805 if (end == start) return; |
806 _checkReadWriteListArguments(buffer.length, start, end); | 806 _checkReadWriteListArguments(buffer.length, start, end); |
807 _BufferAndStart bufferAndStart = | 807 _BufferAndStart bufferAndStart = |
808 _ensureFastAndSerializableBuffer(buffer, start, end); | 808 _ensureFastAndSerializableData(buffer, start, end); |
809 var result = _writeFrom(_id, | 809 var result = _writeFrom(_id, |
810 bufferAndStart.buffer, | 810 bufferAndStart.buffer, |
811 bufferAndStart.start, | 811 bufferAndStart.start, |
812 end - (start - bufferAndStart.start)); | 812 end - (start - bufferAndStart.start)); |
813 if (result is OSError) { | 813 if (result is OSError) { |
814 throw new FileException("writeFrom failed for file '$_path'", result); | 814 throw new FileException("writeFrom failed for file '$_path'", result); |
815 } | 815 } |
816 } | 816 } |
817 | 817 |
818 Future<RandomAccessFile> writeString(String string, | 818 Future<RandomAccessFile> writeString(String string, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 | 981 |
982 Future _closedException() { | 982 Future _closedException() { |
983 return new Future.error(new FileException("File closed '$_path'")); | 983 return new Future.error(new FileException("File closed '$_path'")); |
984 } | 984 } |
985 | 985 |
986 final String _path; | 986 final String _path; |
987 int _id; | 987 int _id; |
988 | 988 |
989 SendPort _fileService; | 989 SendPort _fileService; |
990 } | 990 } |
OLD | NEW |