Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: sdk/lib/io/file_impl.dart

Issue 18115002: Make writes consistent across socket and file synchronous/asynchronus writes in terms of truncation… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/common.dart ('k') | tests/standalone/io/file_typed_data_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 }
OLDNEW
« no previous file with comments | « sdk/lib/io/common.dart ('k') | tests/standalone/io/file_typed_data_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698