| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 void _pipe(InputStream input, OutputStream output, [bool close]) { |
| 6 Function pipeDataHandler; |
| 7 Function pipeCloseHandler; |
| 8 Function pipeNoPendingWriteHandler; |
| 9 |
| 10 Function _inputCloseHandler; |
| 11 |
| 12 pipeDataHandler = () { |
| 13 List<int> data; |
| 14 while ((data = input.read()) !== null) { |
| 15 if (!output.write(data)) { |
| 16 input.dataHandler = null; |
| 17 output.noPendingWriteHandler = pipeNoPendingWriteHandler; |
| 18 break; |
| 19 } |
| 20 } |
| 21 }; |
| 22 |
| 23 pipeCloseHandler = () { |
| 24 if (close) output.close(); |
| 25 if (_inputCloseHandler !== null) _inputCloseHandler(); |
| 26 }; |
| 27 |
| 28 pipeNoPendingWriteHandler = () { |
| 29 input.dataHandler = pipeDataHandler; |
| 30 output.noPendingWriteHandler = null; |
| 31 }; |
| 32 |
| 33 _inputCloseHandler = input._clientCloseHandler; |
| 34 input.dataHandler = pipeDataHandler; |
| 35 input.closeHandler = pipeCloseHandler; |
| 36 output.noPendingWriteHandler = null; |
| 37 } |
| 38 |
| OLD | NEW |