| Index: runtime/bin/stdio_patch.dart
|
| diff --git a/runtime/bin/stdio_patch.dart b/runtime/bin/stdio_patch.dart
|
| index bcdc671aea511af35ac17df1a4bbad222ffde869..5dd5d87c2a8e4c1111c911a078f41ea4e65cc371 100644
|
| --- a/runtime/bin/stdio_patch.dart
|
| +++ b/runtime/bin/stdio_patch.dart
|
| @@ -3,8 +3,39 @@
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| patch class _StdIOUtils {
|
| - /* patch */ static _getStdioHandle(Socket socket, int num)
|
| - native "Socket_GetStdioHandle";
|
| - /* patch */ static _getStdioHandleType(int num)
|
| - native "File_GetStdioHandleType";
|
| + static InputStream _getStdioInputStream() {
|
| + switch (_getStdioHandleType(0)) {
|
| + case _STDIO_HANDLE_TYPE_TERMINAL:
|
| + case _STDIO_HANDLE_TYPE_PIPE:
|
| + case _STDIO_HANDLE_TYPE_SOCKET:
|
| + Socket s = new _Socket._internalReadOnly();
|
| + _getStdioHandle(s, 0);
|
| + s._closed = false;
|
| + return s.inputStream;
|
| + case _STDIO_HANDLE_TYPE_FILE:
|
| + return new _FileInputStream.fromStdio(0);
|
| + default:
|
| + throw new FileIOException("Unsupported stdin type");
|
| + }
|
| + }
|
| +
|
| + static OutputStream _getStdioOutputStream(int fd) {
|
| + assert(fd == 1 || fd == 2);
|
| + switch (_getStdioHandleType(fd)) {
|
| + case _STDIO_HANDLE_TYPE_TERMINAL:
|
| + case _STDIO_HANDLE_TYPE_PIPE:
|
| + case _STDIO_HANDLE_TYPE_SOCKET:
|
| + Socket s = new _Socket._internalWriteOnly();
|
| + _getStdioHandle(s, fd);
|
| + s._closed = false;
|
| + return s.outputStream;
|
| + case _STDIO_HANDLE_TYPE_FILE:
|
| + return new _FileOutputStream.fromStdio(fd);
|
| + default:
|
| + throw new FileIOException("Unsupported stdin type");
|
| + }
|
| + }
|
| }
|
| +
|
| +_getStdioHandle(Socket socket, int num) native "Socket_GetStdioHandle";
|
| +_getStdioHandleType(int num) native "File_GetStdioHandleType";
|
|
|