Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: runtime/bin/stream_util.dart

Issue 8933029: Add pipe to input stream (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comment Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698