| 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 @patch 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: |
| 11 return new Stdin._(new _Socket._readPipe(0)); | 11 return new Stdin._(new _Socket._readPipe(0)); |
| 12 case _STDIO_HANDLE_TYPE_FILE: | 12 case _STDIO_HANDLE_TYPE_FILE: |
| 13 return new Stdin._(new _FileStream.forStdin()); | 13 return new Stdin._(new _FileStream.forStdin()); |
| 14 default: | 14 default: |
| 15 throw new FileSystemException("Unsupported stdin type"); | 15 throw new FileSystemException("Unsupported stdin type"); |
| 16 } | 16 } |
| 17 } | 17 } |
| 18 | 18 |
| 19 @patch static _getStdioOutputStream(int fd) { | 19 static _getStdioOutputStream(int fd) { |
| 20 assert(fd == 1 || fd == 2); | 20 assert(fd == 1 || fd == 2); |
| 21 switch (_getStdioHandleType(fd)) { | 21 switch (_getStdioHandleType(fd)) { |
| 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 @patch static int _socketType(Socket socket) { | 32 static int _socketType(Socket socket) { |
| 33 if (socket is _Socket) return _nativeSocketType(socket._nativeSocket); | 33 if (socket is _Socket) return _nativeSocketType(socket._nativeSocket); |
| 34 return null; | 34 return null; |
| 35 } | 35 } |
| 36 | 36 |
| 37 @patch static int _nativeSocketType(_NativeSocket nativeSocket) { | 37 static int _nativeSocketType(_NativeSocket nativeSocket) { |
| 38 var result = _getSocketType(nativeSocket); | 38 var result = _getSocketType(nativeSocket); |
| 39 if (result is OSError) { | 39 if (result is OSError) { |
| 40 throw new FileSystemException( | 40 throw new FileSystemException( |
| 41 "Error retrieving socket type", "", result); | 41 "Error retrieving socket type", "", result); |
| 42 } | 42 } |
| 43 return result; | 43 return result; |
| 44 } | 44 } |
| 45 | 45 |
| 46 @patch static _getStdioHandleType(int fd) native "File_GetStdioHandleType"; | 46 static _getStdioHandleType(int fd) native "File_GetStdioHandleType"; |
| 47 } | 47 } |
| 48 | 48 |
| 49 @patch class Stdin { | 49 @patch class Stdin { |
| 50 @patch int readByteSync() native "Stdin_ReadByte"; | 50 @patch int readByteSync() native "Stdin_ReadByte"; |
| 51 | 51 |
| 52 @patch bool get echoMode => _echoMode; | 52 @patch bool get echoMode => _echoMode; |
| 53 @patch void set echoMode(bool enabled) { _echoMode = enabled; } | 53 @patch void set echoMode(bool enabled) { _echoMode = enabled; } |
| 54 | 54 |
| 55 @patch bool get lineMode => _lineMode; | 55 @patch bool get lineMode => _lineMode; |
| 56 @patch void set lineMode(bool enabled) { _lineMode = enabled; } | 56 @patch void set lineMode(bool enabled) { _lineMode = enabled; } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 81 } | 81 } |
| 82 return size; | 82 return size; |
| 83 } | 83 } |
| 84 | 84 |
| 85 static _getTerminalSize(int fd) native "Stdout_GetTerminalSize"; | 85 static _getTerminalSize(int fd) native "Stdout_GetTerminalSize"; |
| 86 } | 86 } |
| 87 | 87 |
| 88 | 88 |
| 89 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; | 89 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; |
| 90 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; | 90 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; |
| OLD | NEW |