| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 // Read the file in blocks of size 64k. | 7 // Read the file in blocks of size 64k. |
| 8 const int _BLOCK_SIZE = 64 * 1024; | 8 const int _BLOCK_SIZE = 64 * 1024; |
| 9 | 9 |
| 10 | 10 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 | 170 |
| 171 class _FileStreamConsumer extends StreamConsumer<List<int>> { | 171 class _FileStreamConsumer extends StreamConsumer<List<int>> { |
| 172 File _file; | 172 File _file; |
| 173 Future<RandomAccessFile> _openFuture; | 173 Future<RandomAccessFile> _openFuture; |
| 174 | 174 |
| 175 _FileStreamConsumer(File this._file, FileMode mode) { | 175 _FileStreamConsumer(File this._file, FileMode mode) { |
| 176 _openFuture = _file.open(mode: mode); | 176 _openFuture = _file.open(mode: mode); |
| 177 } | 177 } |
| 178 | 178 |
| 179 _FileStreamConsumer.fromStdio(int fd) { |
| 180 assert(1 <= fd && fd <= 2); |
| 181 _openFuture = new Future.value(_File._openStdioSync(fd)); |
| 182 } |
| 183 |
| 179 Future<File> addStream(Stream<List<int>> stream) { | 184 Future<File> addStream(Stream<List<int>> stream) { |
| 180 Completer<File> completer = new Completer<File>.sync(); | 185 Completer<File> completer = new Completer<File>.sync(); |
| 181 _openFuture | 186 _openFuture |
| 182 .then((openedFile) { | 187 .then((openedFile) { |
| 183 var _subscription; | 188 var _subscription; |
| 184 void error(e, [StackTrace stackTrace]) { | 189 void error(e, [StackTrace stackTrace]) { |
| 185 _subscription.cancel(); | 190 _subscription.cancel(); |
| 186 openedFile.close(); | 191 openedFile.close(); |
| 187 completer.completeError(e, stackTrace); | 192 completer.completeError(e, stackTrace); |
| 188 } | 193 } |
| (...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 void _checkAvailable() { | 969 void _checkAvailable() { |
| 965 if (_asyncDispatched) { | 970 if (_asyncDispatched) { |
| 966 throw new FileSystemException("An async operation is currently pending", | 971 throw new FileSystemException("An async operation is currently pending", |
| 967 path); | 972 path); |
| 968 } | 973 } |
| 969 if (closed) { | 974 if (closed) { |
| 970 throw new FileSystemException("File closed", path); | 975 throw new FileSystemException("File closed", path); |
| 971 } | 976 } |
| 972 } | 977 } |
| 973 } | 978 } |
| OLD | NEW |