Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Side by Side Diff: runtime/bin/stdio_patch.dart

Issue 12316036: Merge IO v2 branch to bleeding edge (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased to r18818 Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/socket_win.cc ('k') | runtime/bin/utf_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 InputStream _getStdioInputStream() { 6 static Stream<List<int>> _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 Socket s = new _Socket._internalReadOnly(); 11 return new _Socket._readPipe(0);
12 _getStdioHandle(s, 0);
13 s._closed = false;
14 return s.inputStream;
15 case _STDIO_HANDLE_TYPE_FILE: 12 case _STDIO_HANDLE_TYPE_FILE:
16 return new _FileInputStream.fromStdio(0); 13 return new _FileStream.forStdin();
17 default: 14 default:
18 throw new FileIOException("Unsupported stdin type"); 15 throw new FileIOException("Unsupported stdin type");
19 } 16 }
20 } 17 }
21 18
22 static OutputStream _getStdioOutputStream(int fd) { 19 static IOSink _getStdioOutputStream(int fd) {
23 assert(fd == 1 || fd == 2); 20 assert(fd == 1 || fd == 2);
24 switch (_getStdioHandleType(fd)) { 21 switch (_getStdioHandleType(fd)) {
25 case _STDIO_HANDLE_TYPE_TERMINAL: 22 case _STDIO_HANDLE_TYPE_TERMINAL:
26 case _STDIO_HANDLE_TYPE_PIPE: 23 case _STDIO_HANDLE_TYPE_PIPE:
27 case _STDIO_HANDLE_TYPE_SOCKET: 24 case _STDIO_HANDLE_TYPE_SOCKET:
28 Socket s = new _Socket._internalWriteOnly(); 25 return new _Socket._writePipe(fd);
29 _getStdioHandle(s, fd);
30 s._closed = false;
31 return s.outputStream;
32 case _STDIO_HANDLE_TYPE_FILE: 26 case _STDIO_HANDLE_TYPE_FILE:
33 return new _FileOutputStream.fromStdio(fd); 27 return new IOSink(new _FileStreamConsumer.fromStdio(fd));
34 default: 28 default:
35 throw new FileIOException("Unsupported stdin type"); 29 throw new FileIOException("Unsupported stdin type");
36 } 30 }
37 } 31 }
38 32
39 static int _socketType(Socket socket) { 33 static int _socketType(nativeSocket) {
40 return _getSocketType(socket); 34 return _getSocketType(nativeSocket);
41 } 35 }
42 } 36 }
43 37
44 38
45 _getStdioHandle(Socket socket, int num) native "Socket_GetStdioHandle"; 39 _getStdioHandle(_NativeSocket socket, int num) native "Socket_GetStdioHandle";
46 _getStdioHandleType(int num) native "File_GetStdioHandleType"; 40 _getStdioHandleType(int num) native "File_GetStdioHandleType";
47 _getSocketType(Socket socket) native "Socket_GetType"; 41 _getSocketType(_NativeSocket nativeSocket) native "Socket_GetType";
OLDNEW
« no previous file with comments | « runtime/bin/socket_win.cc ('k') | runtime/bin/utf_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698