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 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; |
11 const int _STDIO_HANDLE_TYPE_OTHER = 4; | 11 const int _STDIO_HANDLE_TYPE_OTHER = 4; |
12 | 12 |
13 class _StdStream extends Stream<List<int>> { | 13 class _StdStream extends Stream<List<int>> { |
14 final Stream<List<int>> _stream; | 14 final Stream<List<int>> _stream; |
15 | 15 |
16 _StdStream(Stream<List<int>> this._stream); | 16 _StdStream(Stream<List<int>> this._stream); |
17 | 17 |
18 StreamSubscription<List<int>> listen(void onData(List<int> event), | 18 StreamSubscription<List<int>> listen(void onData(List<int> event), |
19 {void onError(AsyncError error), | 19 {void onError(error), |
20 void onDone(), | 20 void onDone(), |
21 bool cancelOnError}) { | 21 bool cancelOnError}) { |
22 return _stream.listen( | 22 return _stream.listen( |
23 onData, | 23 onData, |
24 onError: onError, | 24 onError: onError, |
25 onDone: onDone, | 25 onDone: onDone, |
26 cancelOnError: cancelOnError); | 26 cancelOnError: cancelOnError); |
27 } | 27 } |
28 } | 28 } |
29 | 29 |
30 class _StdSink implements IOSink { | 30 class _StdSink implements IOSink { |
31 final IOSink _sink; | 31 final IOSink _sink; |
32 | 32 |
33 _StdSink(IOSink this._sink); | 33 _StdSink(IOSink this._sink); |
34 | 34 |
35 Encoding get encoding => _sink.encoding; | 35 Encoding get encoding => _sink.encoding; |
36 void set encoding(Encoding encoding) { | 36 void set encoding(Encoding encoding) { |
37 _sink.encoding = encoding; | 37 _sink.encoding = encoding; |
38 } | 38 } |
39 void write(object) => _sink.write(object); | 39 void write(object) => _sink.write(object); |
40 void writeln([object = "" ]) => _sink.writeln(object); | 40 void writeln([object = "" ]) => _sink.writeln(object); |
41 void writeAll(objects, [sep = ""]) => _sink.writeAll(objects, sep); | 41 void writeAll(objects, [sep = ""]) => _sink.writeAll(objects, sep); |
42 void add(List<int> data) => _sink.add(data); | 42 void add(List<int> data) => _sink.add(data); |
43 void addError(AsyncError error) => _sink.addError(error); | 43 void addError(error) => _sink.addError(error); |
44 void writeCharCode(int charCode) => _sink.writeCharCode(charCode); | 44 void writeCharCode(int charCode) => _sink.writeCharCode(charCode); |
45 Future addStream(Stream<List<int>> stream) => _sink.addStream(stream); | 45 Future addStream(Stream<List<int>> stream) => _sink.addStream(stream); |
46 Future close() => _sink.close(); | 46 Future close() => _sink.close(); |
47 Future get done => _sink.done; | 47 Future get done => _sink.done; |
48 } | 48 } |
49 | 49 |
50 class StdioType { | 50 class StdioType { |
51 static const StdioType TERMINAL = const StdioType._("terminal"); | 51 static const StdioType TERMINAL = const StdioType._("terminal"); |
52 static const StdioType PIPE = const StdioType._("pipe"); | 52 static const StdioType PIPE = const StdioType._("pipe"); |
53 static const StdioType FILE = const StdioType._("file"); | 53 static const StdioType FILE = const StdioType._("file"); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 114 } |
115 return StdioType.OTHER; | 115 return StdioType.OTHER; |
116 } | 116 } |
117 | 117 |
118 | 118 |
119 class _StdIOUtils { | 119 class _StdIOUtils { |
120 external static IOSink _getStdioOutputStream(int fd); | 120 external static IOSink _getStdioOutputStream(int fd); |
121 external static Stream<List<int>> _getStdioInputStream(); | 121 external static Stream<List<int>> _getStdioInputStream(); |
122 external static int _socketType(nativeSocket); | 122 external static int _socketType(nativeSocket); |
123 } | 123 } |
OLD | NEW |