| 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 20 matching lines...) Expand all Loading... |
| 31 return _fillBuffer(); | 31 return _fillBuffer(); |
| 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 void _closeFile() { | 40 void _closeFile() { |
| 41 if (available() == 0) _cancelScheduledDataCallback(); |
| 41 if (!_openedFile.closed) { | 42 if (!_openedFile.closed) { |
| 42 _openedFile.close().then((ignore) { | 43 _openedFile.close().then((ignore) { |
| 43 _streamMarkedClosed = true; | 44 _streamMarkedClosed = true; |
| 44 _checkScheduleCallbacks(); | 45 _checkScheduleCallbacks(); |
| 45 }); | 46 }); |
| 46 } | 47 } |
| 47 } | 48 } |
| 48 | 49 |
| 49 Future<int> _fillBuffer() { | 50 Future<int> _fillBuffer() { |
| 50 Expect.equals(_position, _data.length); | 51 Expect.equals(_position, _data.length); |
| (...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 new FileIOException("File closed '$_name'")); | 1132 new FileIOException("File closed '$_name'")); |
| 1132 }); | 1133 }); |
| 1133 return completer.future; | 1134 return completer.future; |
| 1134 } | 1135 } |
| 1135 | 1136 |
| 1136 final String _name; | 1137 final String _name; |
| 1137 int _id; | 1138 int _id; |
| 1138 | 1139 |
| 1139 SendPort _fileService; | 1140 SendPort _fileService; |
| 1140 } | 1141 } |
| OLD | NEW |