Chromium Code Reviews| 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: |
| 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 static _getStdioOutputStream(int fd) { | 19 static _getStdioOutputStream(int fd) { |
| 20 wrap(sink) { | 20 wrap(sink) { |
| 21 if (fd == 1) { | 21 if (fd == 1) { |
| 22 return new Stdout._(sink); | 22 return new Stdout._(sink); |
| 23 } else { | 23 } else { |
| 24 return new _StdSink(sink); | 24 return new _StdSink(sink); |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 assert(fd == 1 || fd == 2); | 27 assert(fd == 1 || fd == 2); |
| 28 switch (_getStdioHandleType(fd)) { | 28 switch (_getStdioHandleType(fd)) { |
|
Ivan Posva
2014/02/11 04:08:37
Do we now really care what kind of file type stdou
Anders Johnsen
2014/02/14 08:43:28
One should consider stdout and not stdin when deci
| |
| 29 case _STDIO_HANDLE_TYPE_TERMINAL: | 29 case _STDIO_HANDLE_TYPE_TERMINAL: |
| 30 case _STDIO_HANDLE_TYPE_PIPE: | 30 case _STDIO_HANDLE_TYPE_PIPE: |
| 31 case _STDIO_HANDLE_TYPE_SOCKET: | 31 case _STDIO_HANDLE_TYPE_SOCKET: |
| 32 return wrap(new _Socket._writePipe(fd)); | |
| 33 case _STDIO_HANDLE_TYPE_FILE: | 32 case _STDIO_HANDLE_TYPE_FILE: |
| 34 return wrap(new IOSink(new _FileStreamConsumer.fromStdio(fd))); | 33 return wrap(new IOSink(new _FileStreamConsumer.fromStdio(fd))); |
| 35 default: | 34 default: |
| 36 throw new FileSystemException("Unsupported stdin type"); | 35 throw new FileSystemException("Unsupported stdin type"); |
| 37 } | 36 } |
| 38 } | 37 } |
| 39 | 38 |
| 40 static int _socketType(nativeSocket) { | 39 static int _socketType(nativeSocket) { |
| 41 var result = _getSocketType(nativeSocket); | 40 var result = _getSocketType(nativeSocket); |
| 42 if (result is OSError) { | 41 if (result is OSError) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 return size; | 81 return size; |
| 83 } | 82 } |
| 84 | 83 |
| 85 static _getTerminalSize() native "Stdout_GetTerminalSize"; | 84 static _getTerminalSize() native "Stdout_GetTerminalSize"; |
| 86 } | 85 } |
| 87 | 86 |
| 88 | 87 |
| 89 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; | 88 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle"; |
| 90 _getStdioHandleType(int num) native "File_GetStdioHandleType"; | 89 _getStdioHandleType(int num) native "File_GetStdioHandleType"; |
| 91 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; | 90 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType"; |
| OLD | NEW |