OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of dart.io; | 5 part of dart.io; |
6 | 6 |
7 /** | 7 /** |
8 * Helper class to wrap a [StreamConsumer<List<int>>] and provide | 8 * Helper class to wrap a [StreamConsumer<List<int>>] and provide |
9 * utility functions for writing to the StreamConsumer directly. The | 9 * utility functions for writing to the StreamConsumer directly. The |
10 * [IOSink] buffers the input given by all [StringSink] methods and will delay | 10 * [IOSink] buffers the input given by all [StringSink] methods and will delay |
(...skipping 28 matching lines...) Expand all Loading... | |
39 * Writes an error to the consumer. | 39 * Writes an error to the consumer. |
40 */ | 40 */ |
41 void addError(error); | 41 void addError(error); |
42 | 42 |
43 /** | 43 /** |
44 * Adds all elements of the given [stream] to `this`. | 44 * Adds all elements of the given [stream] to `this`. |
45 */ | 45 */ |
46 Future addStream(Stream<List<int>> stream); | 46 Future addStream(Stream<List<int>> stream); |
47 | 47 |
48 /** | 48 /** |
49 * Flushes the data currently added to the stream to underlying | |
50 * storage if possible. | |
51 * | |
52 * Returns a future which completes when the flush operation is | |
53 * complete. | |
54 * | |
55 * Currently this method only has effect if the target of the | |
56 * [IOSink] is a file. For all other targets this does nothing | |
57 * and the returned future completed immediately. | |
58 * | |
59 * If [add] is used to write to the [IOSink] all data written using | |
60 * [add] before calling [flush] will be flushed. If [addStream] is | |
61 * used and [flush] is called before the future returned from | |
62 * [addStream] is complete the abount of data which will be flushed | |
63 * is undefined. | |
64 */ | |
65 Future flush(); | |
66 | |
67 /** | |
49 * Close the target. | 68 * Close the target. |
50 */ | 69 */ |
51 Future close(); | 70 Future close(); |
52 | 71 |
53 /** | 72 /** |
54 * Get a future that will complete when all synchronous have completed, or an | 73 * Get a future that will complete when all synchronous have completed, or an |
55 * error happened. This future is identical to the future returned from close. | 74 * error happened. This future is identical to the future returned from close. |
56 */ | 75 */ |
57 Future get done; | 76 Future get done; |
58 } | 77 } |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
224 } | 243 } |
225 | 244 |
226 void writeln([Object obj = ""]) { | 245 void writeln([Object obj = ""]) { |
227 write(obj); | 246 write(obj); |
228 write("\n"); | 247 write("\n"); |
229 } | 248 } |
230 | 249 |
231 void writeCharCode(int charCode) { | 250 void writeCharCode(int charCode) { |
232 write(new String.fromCharCode(charCode)); | 251 write(new String.fromCharCode(charCode)); |
233 } | 252 } |
253 | |
254 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
| |
255 if (_target is _FileStreamConsumer) { | |
256 return _target.flush(); | |
257 } else { | |
258 return new Future.value(null); | |
259 } | |
260 } | |
234 } | 261 } |
OLD | NEW |