| 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 | 5 @patch |
| 6 class _StdIOUtils { | 6 class _StdIOUtils { |
| 7 @patch | 7 @patch |
| 8 static Stdin _getStdioInputStream() { | 8 static Stdin _getStdioInputStream() { |
| 9 switch (_getStdioHandleType(0)) { | 9 switch (_getStdioHandleType(0)) { |
| 10 case _STDIO_HANDLE_TYPE_TERMINAL: | 10 case _STDIO_HANDLE_TYPE_TERMINAL: |
| 11 case _STDIO_HANDLE_TYPE_PIPE: | 11 case _STDIO_HANDLE_TYPE_PIPE: |
| 12 case _STDIO_HANDLE_TYPE_SOCKET: | 12 case _STDIO_HANDLE_TYPE_SOCKET: |
| 13 return new Stdin._(new _Socket._readPipe(0)); | 13 return new Stdin._(new _Socket._readPipe(0)); |
| 14 case _STDIO_HANDLE_TYPE_FILE: | 14 case _STDIO_HANDLE_TYPE_FILE: |
| 15 return new Stdin._(new _FileStream.forStdin()); | 15 return new Stdin._(new _FileStream.forStdin()); |
| 16 default: | 16 default: |
| 17 throw new FileSystemException("Unsupported stdin type"); | 17 throw new FileSystemException( |
| 18 "Couldn't determine file type of stdin (fd 0)"); |
| 18 } | 19 } |
| 19 } | 20 } |
| 20 | 21 |
| 21 @patch | 22 @patch |
| 22 static _getStdioOutputStream(int fd) { | 23 static _getStdioOutputStream(int fd) { |
| 23 assert(fd == 1 || fd == 2); | 24 assert(fd == 1 || fd == 2); |
| 24 switch (_getStdioHandleType(fd)) { | 25 switch (_getStdioHandleType(fd)) { |
| 25 case _STDIO_HANDLE_TYPE_TERMINAL: | 26 case _STDIO_HANDLE_TYPE_TERMINAL: |
| 26 case _STDIO_HANDLE_TYPE_PIPE: | 27 case _STDIO_HANDLE_TYPE_PIPE: |
| 27 case _STDIO_HANDLE_TYPE_SOCKET: | 28 case _STDIO_HANDLE_TYPE_SOCKET: |
| 28 case _STDIO_HANDLE_TYPE_FILE: | 29 case _STDIO_HANDLE_TYPE_FILE: |
| 29 return new Stdout._(new IOSink(new _StdConsumer(fd)), fd); | 30 return new Stdout._(new IOSink(new _StdConsumer(fd)), fd); |
| 30 default: | 31 default: |
| 31 throw new FileSystemException("Unsupported stdin type"); | 32 throw new FileSystemException( |
| 33 "Couldn't determine file type of stdio handle (fd $fd)"); |
| 32 } | 34 } |
| 33 } | 35 } |
| 34 | 36 |
| 35 @patch | 37 @patch |
| 36 static int _socketType(Socket socket) { | 38 static int _socketType(Socket socket) { |
| 37 if (socket is _Socket) return _nativeSocketType(socket._nativeSocket); | 39 if (socket is _Socket) return _nativeSocketType(socket._nativeSocket); |
| 38 return null; | 40 return null; |
| 39 } | 41 } |
| 40 | 42 |
| 41 static int _nativeSocketType(_NativeSocket nativeSocket) { | 43 static int _nativeSocketType(_NativeSocket nativeSocket) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 throw new StdoutException("Error determining ANSI support", result); | 146 throw new StdoutException("Error determining ANSI support", result); |
| 145 } | 147 } |
| 146 return result; | 148 return result; |
| 147 } | 149 } |
| 148 | 150 |
| 149 static _getAnsiSupported(int fd) native "Stdout_AnsiSupported"; | 151 static _getAnsiSupported(int fd) native "Stdout_AnsiSupported"; |
| 150 } | 152 } |
| 151 | 153 |
| 152 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; | 154 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; |
| 153 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; | 155 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; |
| OLD | NEW |