| 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 patch class _StdIOUtils { | 5 patch class _StdIOUtils { |
| 6 static Stdin _getStdioInputStream() { | 6 static Stdin _getStdioInputStream() { |
| 7 switch (_getStdioHandleType(0)) { | 7 switch (_getStdioHandleType(0)) { |
| 8 case _STDIO_HANDLE_TYPE_TERMINAL: | 8 case _STDIO_HANDLE_TYPE_TERMINAL: |
| 9 case _STDIO_HANDLE_TYPE_PIPE: | 9 case _STDIO_HANDLE_TYPE_PIPE: |
| 10 case _STDIO_HANDLE_TYPE_SOCKET: | 10 case _STDIO_HANDLE_TYPE_SOCKET: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 case _STDIO_HANDLE_TYPE_TERMINAL: | 22 case _STDIO_HANDLE_TYPE_TERMINAL: |
| 23 case _STDIO_HANDLE_TYPE_PIPE: | 23 case _STDIO_HANDLE_TYPE_PIPE: |
| 24 case _STDIO_HANDLE_TYPE_SOCKET: | 24 case _STDIO_HANDLE_TYPE_SOCKET: |
| 25 case _STDIO_HANDLE_TYPE_FILE: | 25 case _STDIO_HANDLE_TYPE_FILE: |
| 26 return new Stdout._(new IOSink(new _StdConsumer(fd)), fd); | 26 return new Stdout._(new IOSink(new _StdConsumer(fd)), fd); |
| 27 default: | 27 default: |
| 28 throw new FileSystemException("Unsupported stdin type"); | 28 throw new FileSystemException("Unsupported stdin type"); |
| 29 } | 29 } |
| 30 } | 30 } |
| 31 | 31 |
| 32 static int _socketType(nativeSocket) { | 32 static int _socketType(Socket socket) { |
| 33 var result = _getSocketType(nativeSocket); | 33 if (socket is _Socket) { |
| 34 if (result is OSError) { | 34 var nativeSocket = socket._nativeSocket; |
| 35 throw new FileSystemException("Error retrieving socket type", "", result); | 35 var result = _getSocketType(nativeSocket); |
| 36 if (result is OSError) { |
| 37 throw new FileSystemException( |
| 38 "Error retrieving socket type", "", result); |
| 39 } |
| 40 return result; |
| 36 } | 41 } |
| 37 return result; | 42 return null; |
| 38 } | 43 } |
| 39 | 44 |
| 40 static _getStdioHandleType(int fd) native "File_GetStdioHandleType"; | 45 static _getStdioHandleType(int fd) native "File_GetStdioHandleType"; |
| 41 } | 46 } |
| 42 | 47 |
| 43 patch class Stdin { | 48 patch class Stdin { |
| 44 /* patch */ int readByteSync() native "Stdin_ReadByte"; | 49 /* patch */ int readByteSync() native "Stdin_ReadByte"; |
| 45 | 50 |
| 46 /* patch */ bool get echoMode => _echoMode; | 51 /* patch */ bool get echoMode => _echoMode; |
| 47 /* patch */ void set echoMode(bool enabled) { _echoMode = enabled; } | 52 /* patch */ void set echoMode(bool enabled) { _echoMode = enabled; } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 75 } | 80 } |
| 76 return size; | 81 return size; |
| 77 } | 82 } |
| 78 | 83 |
| 79 static _getTerminalSize(int fd) native "Stdout_GetTerminalSize"; | 84 static _getTerminalSize(int fd) native "Stdout_GetTerminalSize"; |
| 80 } | 85 } |
| 81 | 86 |
| 82 | 87 |
| 83 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; | 88 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; |
| 84 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; | 89 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; |
| OLD | NEW |