Chromium Code Reviews| Index: sdk/lib/io/io_sink.dart |
| diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart |
| index ac4ce0a1daabeeece9aa0e78da3e55533a5750cf..de4122db95b4f1cf60e98587b8cf09b3bd0ab8a7 100644 |
| --- a/sdk/lib/io/io_sink.dart |
| +++ b/sdk/lib/io/io_sink.dart |
| @@ -46,6 +46,18 @@ abstract class IOSink implements StreamSink<List<int>>, StringSink { |
| Future addStream(Stream<List<int>> stream); |
| /** |
| + * Flushes the data currently buffered in the stream through the |
| + * synchronous Sink methods, to the underlying storage, if possible. |
| + * |
| + * Returns a future which completes when the flush operation is |
| + * complete. If the target of the [IOSink] is a file then a file |
| + * system flush will be performed as well. |
| + * |
| + * If [addStream] is currently active this method will fail. |
| + */ |
| + Future flush(); |
|
Anders Johnsen
2013/10/28 15:13:22
I still disagree that this should be part of the I
|
| + |
| + /** |
| * Close the target. |
| */ |
| Future close(); |
| @@ -231,4 +243,15 @@ class _IOSinkImpl extends _StreamSinkImpl<List<int>> implements IOSink { |
| void writeCharCode(int charCode) { |
| write(new String.fromCharCode(charCode)); |
| } |
| + |
| + Future flush() { |
| + return addStream((new StreamController()..close()).stream) |
| + .then((_) { |
| + if (_target is _FileStreamConsumer) { |
| + return _target.flush(); |
| + } else { |
| + return new Future.value(null); |
| + } |
| + }); |
| + } |
| } |