| Index: sdk/lib/io/io_sink.dart
|
| diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart
|
| index 685024cd09715f2e00d026502865cae1b76c73cb..794095e68d56132899f2b13816857e86a9b77cbc 100644
|
| --- a/sdk/lib/io/io_sink.dart
|
| +++ b/sdk/lib/io/io_sink.dart
|
| @@ -8,14 +8,15 @@ part of dart.io;
|
| * Helper class to wrap a [StreamConsumer<List<int>, T>] and provide
|
| * utility functions for writing to the StreamConsumer directly. The
|
| * [IOSink] buffers the input given by [write], [writeAll], [writeln],
|
| - * [writeCharCode] and [writeBytes] and will delay a [consume] or
|
| + * [writeCharCode] and [add] and will delay a [consume] or
|
| * [writeStream] until the buffer is flushed.
|
| *
|
| * When the [IOSink] is bound to a stream (through either [consume]
|
| * or [writeStream]) any call to the [IOSink] will throw a
|
| * [StateError].
|
| */
|
| -abstract class IOSink<T> implements StreamConsumer<List<int>, T>, StringSink {
|
| +abstract class IOSink<T>
|
| + implements StreamConsumer<List<int>, T>, StringSink, EventSink<List<int>> {
|
| factory IOSink(StreamConsumer<List<int>, T> target,
|
| {Encoding encoding: Encoding.UTF_8})
|
| => new _IOSinkImpl(target, encoding);
|
| @@ -29,7 +30,12 @@ abstract class IOSink<T> implements StreamConsumer<List<int>, T>, StringSink {
|
| /**
|
| * Writes the bytes uninterpreted to the consumer.
|
| */
|
| - void writeBytes(List<int> data);
|
| + void add(List<int> data);
|
| +
|
| + /**
|
| + * Writes an error to the consumer.
|
| + */
|
| + void addError(AsyncError error);
|
|
|
| /**
|
| * Provide functionality for piping to the [IOSink].
|
| @@ -100,7 +106,7 @@ class _IOSinkImpl<T> implements IOSink<T> {
|
| }
|
| }
|
| if (string.isEmpty) return;
|
| - writeBytes(_encodeString(string, _encoding));
|
| + add(_encodeString(string, _encoding));
|
| }
|
|
|
| void writeAll(Iterable objects, [String separator = ""]) {
|
| @@ -128,13 +134,20 @@ class _IOSinkImpl<T> implements IOSink<T> {
|
| write(new String.fromCharCode(charCode));
|
| }
|
|
|
| - void writeBytes(List<int> data) {
|
| + void add(List<int> data) {
|
| if (_isBound) {
|
| throw new StateError("IOSink is already bound to a stream");
|
| }
|
| _controller.add(data);
|
| }
|
|
|
| + void addError(AsyncError error) {
|
| + if (_isBound) {
|
| + throw new StateError("IOSink is already bound to a stream");
|
| + }
|
| + _controller.addError(error);
|
| + }
|
| +
|
| Future<T> consume(Stream<List<int>> stream) {
|
| if (_isBound) {
|
| throw new StateError("IOSink is already bound to a stream");
|
|
|