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

Unified Diff: sdk/lib/io/io_sink.dart

Issue 20745006: Add a flush operations to IOSink (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated patch Created 7 years, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ }
+ });
+ }
}
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | tests/standalone/io/file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698