Index: sdk/lib/io/stdio.dart |
diff --git a/sdk/lib/io/stdio.dart b/sdk/lib/io/stdio.dart |
index 5b5e62f539c7b0a669d7760ca83769441ac4ed4c..9c034f437adbca9db958341dea7552cd361eaf79 100644 |
--- a/sdk/lib/io/stdio.dart |
+++ b/sdk/lib/io/stdio.dart |
@@ -202,6 +202,36 @@ class StdoutException implements IOException { |
} |
+class _StdConsumer implements StreamConsumer<List<int>> { |
+ final _file; |
+ |
+ _StdConsumer(int fd) : _file = _File._openStdioSync(fd); |
+ |
+ Future addStream(Stream<List<int>> stream) { |
+ var completer = new Completer(); |
+ var sub; |
+ sub = stream.listen( |
+ (data) { |
+ try { |
+ _file.writeFromSync(data); |
+ } catch (e, s) { |
+ sub.cancel(); |
+ completer.completeError(e, s); |
+ } |
+ }, |
+ onError: completer.completeError, |
+ onDone: completer.complete, |
+ cancelOnError: true); |
+ return completer.future; |
+ } |
+ |
+ Future close() { |
+ _file.closeSync(); |
+ return new Future.value(); |
+ } |
+} |
+ |
+ |
class _StdSink implements IOSink { |
final IOSink _sink; |