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

Side by Side Diff: sdk/lib/io/stdio.dart

Issue 673193002: Make stdout/stderr async (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 const int _STDIO_HANDLE_TYPE_TERMINAL = 0; 7 const int _STDIO_HANDLE_TYPE_TERMINAL = 0;
8 const int _STDIO_HANDLE_TYPE_PIPE = 1; 8 const int _STDIO_HANDLE_TYPE_PIPE = 1;
9 const int _STDIO_HANDLE_TYPE_FILE = 2; 9 const int _STDIO_HANDLE_TYPE_FILE = 2;
10 const int _STDIO_HANDLE_TYPE_SOCKET = 3; 10 const int _STDIO_HANDLE_TYPE_SOCKET = 3;
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 final OSError osError; 184 final OSError osError;
185 185
186 const StdoutException(this.message, [this.osError]); 186 const StdoutException(this.message, [this.osError]);
187 187
188 String toString() { 188 String toString() {
189 return "StdoutException: $message${osError == null ? "" : ", $osError"}"; 189 return "StdoutException: $message${osError == null ? "" : ", $osError"}";
190 } 190 }
191 } 191 }
192 192
193 193
194 class _StdConsumer implements StreamConsumer<List<int>> {
195 final _file;
196
197 _StdConsumer(int fd) : _file = _File._openStdioSync(fd);
198
199 Future addStream(Stream<List<int>> stream) {
200 var completer = new Completer();
201 var sub;
202 sub = stream.listen(
203 (data) {
204 try {
205 _file.writeFromSync(data);
206 } catch (e, s) {
207 sub.cancel();
208 completer.completeError(e, s);
209 }
210 },
211 onError: completer.completeError,
212 onDone: completer.complete,
213 cancelOnError: true);
214 return completer.future;
215 }
216
217 Future close() {
218 _file.closeSync();
219 return new Future.value();
220 }
221 }
222
223
224 class _StdSink implements IOSink { 194 class _StdSink implements IOSink {
225 final IOSink _sink; 195 final IOSink _sink;
226 196
227 _StdSink(this._sink); 197 _StdSink(this._sink);
228 198
229 Encoding get encoding => _sink.encoding; 199 Encoding get encoding => _sink.encoding;
230 void set encoding(Encoding encoding) { 200 void set encoding(Encoding encoding) {
231 _sink.encoding = encoding; 201 _sink.encoding = encoding;
232 } 202 }
233 void write(object) => _sink.write(object); 203 void write(object) => _sink.write(object);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 return StdioType.OTHER; 291 return StdioType.OTHER;
322 } 292 }
323 293
324 294
325 class _StdIOUtils { 295 class _StdIOUtils {
326 external static _getStdioOutputStream(int fd); 296 external static _getStdioOutputStream(int fd);
327 external static Stdin _getStdioInputStream(); 297 external static Stdin _getStdioInputStream();
328 external static int _socketType(nativeSocket); 298 external static int _socketType(nativeSocket);
329 external static _getStdioHandleType(int fd); 299 external static _getStdioHandleType(int fd);
330 } 300 }
OLDNEW
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698