| 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 _file = new File(name); | 7 _file = new File(name); |
| 8 _data = []; | 8 _data = []; |
| 9 _position = 0; | 9 _position = 0; |
| 10 _file.errorHandler = (String s) { | 10 _file.errorHandler = (String s) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 openedFile.length(); | 35 openedFile.length(); |
| 36 openedFile.lengthHandler = (length) { | 36 openedFile.lengthHandler = (length) { |
| 37 var contents = new ByteArray(length); | 37 var contents = new ByteArray(length); |
| 38 if (length != 0) { | 38 if (length != 0) { |
| 39 openedFile.readList(contents, 0, length); | 39 openedFile.readList(contents, 0, length); |
| 40 openedFile.readListHandler = (read) { | 40 openedFile.readListHandler = (read) { |
| 41 if (read != length) { | 41 if (read != length) { |
| 42 if (_clientErrorHandler != null) { | 42 if (_clientErrorHandler != null) { |
| 43 _clientErrorHandler(); | 43 _clientErrorHandler(); |
| 44 } | 44 } |
| 45 } else { |
| 46 _data = contents; |
| 47 } |
| 48 openedFile.close(); |
| 49 openedFile.closeHandler = () { |
| 45 _streamMarkedClosed = true; | 50 _streamMarkedClosed = true; |
| 46 _checkScheduleCallbacks(); | 51 _checkScheduleCallbacks(); |
| 47 } else { | 52 }; |
| 48 _data = contents; | |
| 49 _streamMarkedClosed = true; | |
| 50 _checkScheduleCallbacks(); | |
| 51 } | |
| 52 openedFile.close(); | |
| 53 }; | 53 }; |
| 54 } else { | 54 } else { |
| 55 _streamMarkedClosed = true; | |
| 56 _checkScheduleCallbacks(); | |
| 57 openedFile.close(); | 55 openedFile.close(); |
| 58 } | 56 openedFile.closeHandler = () { |
| 57 _streamMarkedClosed = true; |
| 58 _checkScheduleCallbacks(); |
| 59 }; |
| 60 }; |
| 59 }; | 61 }; |
| 60 } | 62 } |
| 61 | 63 |
| 62 int available() { | 64 int available() { |
| 63 return _closed ? 0 : _data.length - _position; | 65 return _closed ? 0 : _data.length - _position; |
| 64 } | 66 } |
| 65 | 67 |
| 66 void pipe(OutputStream output, [bool close = true]) { | 68 void pipe(OutputStream output, [bool close = true]) { |
| 67 _pipe(this, output, close: close); | 69 _pipe(this, output, close: close); |
| 68 } | 70 } |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 Function _readByteHandler; | 1160 Function _readByteHandler; |
| 1159 Function _readListHandler; | 1161 Function _readListHandler; |
| 1160 Function _noPendingWriteHandler; | 1162 Function _noPendingWriteHandler; |
| 1161 Function _positionHandler; | 1163 Function _positionHandler; |
| 1162 Function _setPositionHandler; | 1164 Function _setPositionHandler; |
| 1163 Function _truncateHandler; | 1165 Function _truncateHandler; |
| 1164 Function _lengthHandler; | 1166 Function _lengthHandler; |
| 1165 Function _flushHandler; | 1167 Function _flushHandler; |
| 1166 Function _errorHandler; | 1168 Function _errorHandler; |
| 1167 } | 1169 } |
| OLD | NEW |