| 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(File file) { | 6 _FileInputStream(File file) { |
| 7 _file = file.openSync(); | 7 _file = file.openSync(); |
| 8 _length = _file.lengthSync(); | 8 _length = _file.lengthSync(); |
| 9 _streamMarkedClosed = true; | 9 _streamMarkedClosed = true; |
| 10 _checkScheduleCallbacks(); | 10 _checkScheduleCallbacks(); |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 | 683 |
| 684 | 684 |
| 685 class _RandomAccessFile implements RandomAccessFile { | 685 class _RandomAccessFile implements RandomAccessFile { |
| 686 _RandomAccessFile(int this._id, String this._name) | 686 _RandomAccessFile(int this._id, String this._name) |
| 687 : _scheduler = new _FileOperationScheduler(), | 687 : _scheduler = new _FileOperationScheduler(), |
| 688 _asyncUsed = false; | 688 _asyncUsed = false; |
| 689 | 689 |
| 690 void close() { | 690 void close() { |
| 691 _asyncUsed = true; | 691 _asyncUsed = true; |
| 692 var handler = (_closeHandler != null) ? _closeHandler : () => null; | 692 var handler = (_closeHandler != null) ? _closeHandler : () => null; |
| 693 var handleOpenResult = (result, ignored) { | 693 var handleCloseResult = (result, ignored) { |
| 694 if (result != -1) { | 694 if (result != -1) { |
| 695 _id = result; | 695 _id = result; |
| 696 handler(); | 696 handler(); |
| 697 } else if (_errorHandler != null) { | 697 } else if (_errorHandler != null) { |
| 698 _errorHandler("Cannot close file: $_name"); | 698 _errorHandler("Cannot close file: $_name"); |
| 699 } | 699 } |
| 700 }; | 700 }; |
| 701 var operation = new _CloseOperation(_id); | 701 var operation = new _CloseOperation(_id); |
| 702 _scheduler.enqueue(operation, handleOpenResult); | 702 _scheduler.enqueue(operation, handleCloseResult); |
| 703 } | 703 } |
| 704 | 704 |
| 705 void closeSync() { | 705 void closeSync() { |
| 706 if (_asyncUsed) { | 706 if (_asyncUsed) { |
| 707 throw new FileIOException( | 707 throw new FileIOException( |
| 708 "Mixed use of synchronous and asynchronous API"); | 708 "Mixed use of synchronous and asynchronous API"); |
| 709 } | 709 } |
| 710 var id = _FileUtils.close(_id); | 710 var id = _FileUtils.close(_id); |
| 711 if (id == -1) { | 711 if (id == -1) { |
| 712 throw new FileIOException("Cannot close file: $_name"); | 712 throw new FileIOException("Cannot close file: $_name"); |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1082 var _readByteHandler; | 1082 var _readByteHandler; |
| 1083 var _readListHandler; | 1083 var _readListHandler; |
| 1084 var _noPendingWriteHandler; | 1084 var _noPendingWriteHandler; |
| 1085 var _positionHandler; | 1085 var _positionHandler; |
| 1086 var _setPositionHandler; | 1086 var _setPositionHandler; |
| 1087 var _truncateHandler; | 1087 var _truncateHandler; |
| 1088 var _lengthHandler; | 1088 var _lengthHandler; |
| 1089 var _flushHandler; | 1089 var _flushHandler; |
| 1090 var _errorHandler; | 1090 var _errorHandler; |
| 1091 } | 1091 } |
| OLD | NEW |