| 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 = const [], | 7 : _data = const [], |
| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 _openedFile.close().then((ignore) { | 53 _openedFile.close().then((ignore) { |
| 54 _streamMarkedClosed = true; | 54 _streamMarkedClosed = true; |
| 55 _checkScheduleCallbacks(); | 55 _checkScheduleCallbacks(); |
| 56 }); | 56 }); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 void _fillBuffer() { | 60 void _fillBuffer() { |
| 61 Expect.equals(_position, _data.length); | 61 Expect.equals(_position, _data.length); |
| 62 if (_openedFile == null) return; // Called before the file is opened. | 62 if (_openedFile == null) return; // Called before the file is opened. |
| 63 int size = Math.min(_bufferLength, _fileLength - _filePosition); | 63 int size = min(_bufferLength, _fileLength - _filePosition); |
| 64 if (size == 0) { | 64 if (size == 0) { |
| 65 _closeFile(); | 65 _closeFile(); |
| 66 return; | 66 return; |
| 67 } | 67 } |
| 68 // If there is currently a _fillBuffer call waiting on readList, | 68 // If there is currently a _fillBuffer call waiting on readList, |
| 69 // let it fill the buffer instead of us. | 69 // let it fill the buffer instead of us. |
| 70 if (_activeFillBufferCall) return; | 70 if (_activeFillBufferCall) return; |
| 71 _activeFillBufferCall = true; | 71 _activeFillBufferCall = true; |
| 72 if (_data.length != size) { | 72 if (_data.length != size) { |
| 73 _data = new Uint8List(size); | 73 _data = new Uint8List(size); |
| (...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 new FileIOException("File closed '$_name'")); | 1161 new FileIOException("File closed '$_name'")); |
| 1162 }); | 1162 }); |
| 1163 return completer.future; | 1163 return completer.future; |
| 1164 } | 1164 } |
| 1165 | 1165 |
| 1166 final String _name; | 1166 final String _name; |
| 1167 int _id; | 1167 int _id; |
| 1168 | 1168 |
| 1169 SendPort _fileService; | 1169 SendPort _fileService; |
| 1170 } | 1170 } |
| OLD | NEW |