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

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

Issue 10537053: Remove erroneous assert from dart:io's File class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: move blank line 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 21 matching lines...) Expand all
32 }); 32 });
33 chained.handleException((e) { 33 chained.handleException((e) {
34 _reportError(e); 34 _reportError(e);
35 return true; 35 return true;
36 }); 36 });
37 chained.then((ignored) => _checkScheduleCallbacks()); 37 chained.then((ignored) => _checkScheduleCallbacks());
38 } 38 }
39 39
40 Future<int> _fillBuffer() { 40 Future<int> _fillBuffer() {
41 Expect.equals(_position, _data.length); 41 Expect.equals(_position, _data.length);
42 Expect.isTrue(_filePosition < _fileLength);
43 42
44 int size = Math.min(_bufferLength, _fileLength - _filePosition); 43 int size = Math.min(_bufferLength, _fileLength - _filePosition);
44 if (size == 0) {
45 _streamMarkedClosed = true;
46 _openedFile.close();
47 return new Future.immediate(0);
48 }
45 if (_data.length != size) { 49 if (_data.length != size) {
46 _data = new Uint8List(size); 50 _data = new Uint8List(size);
47 } 51 }
48 var future = _openedFile.readList(_data, 0, _data.length); 52 var future = _openedFile.readList(_data, 0, _data.length);
49 future = future.transform((read) { 53 future = future.transform((read) {
50 _filePosition += read; 54 _filePosition += read;
51 if (read != _data.length) { 55 if (read != _data.length) {
52 _data.removeRange(read, _data.length - read); 56 _data.removeRange(read, _data.length - read);
53 } 57 }
54 _position = 0; 58 _position = 0;
(...skipping 1040 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 new FileIOException("File closed '$_name'")); 1099 new FileIOException("File closed '$_name'"));
1096 }); 1100 });
1097 return completer.future; 1101 return completer.future;
1098 } 1102 }
1099 1103
1100 final String _name; 1104 final String _name;
1101 int _id; 1105 int _id;
1102 1106
1103 SendPort _fileService; 1107 SendPort _fileService;
1104 } 1108 }
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