| OLD | NEW |
| 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 Loading... |
| 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 _data = _data.getRange(0, read); |
| 76 } | 76 } |
| 77 _position = 0; | 77 _position = 0; |
| 78 | 78 |
| 79 if (_fileLength == _filePosition) { | 79 if (_fileLength == _filePosition) { |
| 80 _closeFile(); | 80 _closeFile(); |
| 81 } | 81 } |
| 82 _checkScheduleCallbacks(); | 82 _checkScheduleCallbacks(); |
| 83 }); | 83 }); |
| 84 } | 84 } |
| 85 | 85 |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 new FileIOException("File closed '$_name'")); | 1141 new FileIOException("File closed '$_name'")); |
| 1142 }); | 1142 }); |
| 1143 return completer.future; | 1143 return completer.future; |
| 1144 } | 1144 } |
| 1145 | 1145 |
| 1146 final String _name; | 1146 final String _name; |
| 1147 int _id; | 1147 int _id; |
| 1148 | 1148 |
| 1149 SendPort _fileService; | 1149 SendPort _fileService; |
| 1150 } | 1150 } |
| OLD | NEW |