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

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: Created 7 years, 5 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 b954a86d5ffeed71ac9f0e15677613193ed04251..f2685a3ec2181c9c9e53190940fc80f12c5692ed 100644
--- a/sdk/lib/io/io_sink.dart
+++ b/sdk/lib/io/io_sink.dart
@@ -46,6 +46,25 @@ abstract class IOSink implements StreamSink<List<int>>, StringSink {
Future addStream(Stream<List<int>> stream);
/**
+ * Flushes the data currently added to the stream to underlying
+ * storage if possible.
+ *
+ * Returns a future which completes when the flush operation is
+ * complete.
+ *
+ * Currently this method only has effect if the target of the
+ * [IOSink] is a file. For all other targets this does nothing
+ * and the returned future completed immediately.
+ *
+ * If [add] is used to write to the [IOSink] all data written using
+ * [add] before calling [flush] will be flushed. If [addStream] is
+ * used and [flush] is called before the future returned from
+ * [addStream] is complete the abount of data which will be flushed
+ * is undefined.
+ */
+ Future flush();
+
+ /**
* Close the target.
*/
Future close();
@@ -231,4 +250,12 @@ class _IOSinkImpl extends _StreamSinkImpl<List<int>> implements IOSink {
void writeCharCode(int charCode) {
write(new String.fromCharCode(charCode));
}
+
+ Future flush() {
Anders Johnsen 2013/08/01 13:54:28 So, several comments and concerns about this appro
Søren Gjesse 2013/08/01 14:29:18 As the comment above states this only does anythin
+ 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