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

Side by Side Diff: runtime/bin/file_impl.dart

Issue 10544110: Fix file buffering code that uses RemoveRange on a fixed-length Uint8 array. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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 | « no previous file | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 class _FileInputStream extends _BaseDataInputStream implements InputStream { 5 class _FileInputStream extends _BaseDataInputStream implements InputStream {
6 _FileInputStream(String name) 6 _FileInputStream(String name)
7 : _data = [], 7 : _data = [],
8 _position = 0, 8 _position = 0,
9 _filePosition = 0 { 9 _filePosition = 0 {
10 var file = new File(name); 10 var file = new File(name);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 _closeFile(); 65 _closeFile();
66 return; 66 return;
67 } 67 }
68 if (_data.length != size) { 68 if (_data.length != size) {
69 _data = new Uint8List(size); 69 _data = new Uint8List(size);
70 } 70 }
71 var future = _openedFile.readList(_data, 0, _data.length); 71 var future = _openedFile.readList(_data, 0, _data.length);
72 future.then((read) { 72 future.then((read) {
73 _filePosition += read; 73 _filePosition += read;
74 if (read != _data.length) { 74 if (read != _data.length) {
75 _data.removeRange(read, _data.length - read); 75 var oldData = _data;
Anders Johnsen 2012/06/12 13:42:33 What about _data = _data.getRange(0, read);
Bill Hesse 2012/06/12 13:47:45 I don't know if that would be a Uint8List. Since
Anders Johnsen 2012/06/12 13:51:24 .getRange() is a object of same type (see runtime/
76 _data = new Uint8List(read);
77 _data.fillRange(0, read, oldData, 0);
76 } 78 }
77 _position = 0; 79 _position = 0;
78 80
79 if (_fileLength == _filePosition) { 81 if (_fileLength == _filePosition) {
80 _closeFile(); 82 _closeFile();
81 } 83 }
82 _checkScheduleCallbacks(); 84 _checkScheduleCallbacks();
83 }); 85 });
84 } 86 }
85 87
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 new FileIOException("File closed '$_name'")); 1143 new FileIOException("File closed '$_name'"));
1142 }); 1144 });
1143 return completer.future; 1145 return completer.future;
1144 } 1146 }
1145 1147
1146 final String _name; 1148 final String _name;
1147 int _id; 1149 int _id;
1148 1150
1149 SendPort _fileService; 1151 SendPort _fileService;
1150 } 1152 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698