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

Side by Side Diff: sdk/lib/io/stdio.dart

Issue 13636003: Fix a number of issues with determining the type of stdio (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 8 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/stdio_patch.dart ('k') | tests/standalone/io/dart_std_io_pipe_script.dart » ('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 part of dart.io; 5 part of dart.io;
6 6
7 const int _STDIO_HANDLE_TYPE_TERMINAL = 0; 7 const int _STDIO_HANDLE_TYPE_TERMINAL = 0;
8 const int _STDIO_HANDLE_TYPE_PIPE = 1; 8 const int _STDIO_HANDLE_TYPE_PIPE = 1;
9 const int _STDIO_HANDLE_TYPE_FILE = 2; 9 const int _STDIO_HANDLE_TYPE_FILE = 2;
10 const int _STDIO_HANDLE_TYPE_SOCKET = 3; 10 const int _STDIO_HANDLE_TYPE_SOCKET = 3;
11 const int _STDIO_HANDLE_TYPE_OTHER = -1; 11 const int _STDIO_HANDLE_TYPE_OTHER = 4;
12 12
13 13
14 class StdioType { 14 class StdioType {
15 static const StdioType TERMINAL = const StdioType._("terminal"); 15 static const StdioType TERMINAL = const StdioType._("terminal");
16 static const StdioType PIPE = const StdioType._("pipe"); 16 static const StdioType PIPE = const StdioType._("pipe");
17 static const StdioType FILE = const StdioType._("file"); 17 static const StdioType FILE = const StdioType._("file");
18 static const StdioType OTHER = const StdioType._("other"); 18 static const StdioType OTHER = const StdioType._("other");
19 final String name;
19 const StdioType._(String this.name); 20 const StdioType._(String this.name);
20 final String name; 21 String toString() => "StdioType: $name";
21 } 22 }
22 23
23 24
24 Stream<List<int>> _stdin; 25 Stream<List<int>> _stdin;
25 IOSink _stdout; 26 IOSink _stdout;
26 IOSink _stderr; 27 IOSink _stderr;
27 28
28 29
29 Stream<List<int>> get stdin { 30 Stream<List<int>> get stdin {
30 if (_stdin == null) { 31 if (_stdin == null) {
(...skipping 25 matching lines...) Expand all
56 } 57 }
57 if (object is Socket) { 58 if (object is Socket) {
58 switch (_StdIOUtils._socketType(object._nativeSocket)) { 59 switch (_StdIOUtils._socketType(object._nativeSocket)) {
59 case _STDIO_HANDLE_TYPE_TERMINAL: return StdioType.TERMINAL; 60 case _STDIO_HANDLE_TYPE_TERMINAL: return StdioType.TERMINAL;
60 case _STDIO_HANDLE_TYPE_PIPE: return StdioType.PIPE; 61 case _STDIO_HANDLE_TYPE_PIPE: return StdioType.PIPE;
61 case _STDIO_HANDLE_TYPE_FILE: return StdioType.FILE; 62 case _STDIO_HANDLE_TYPE_FILE: return StdioType.FILE;
62 } 63 }
63 } 64 }
64 if (object is IOSink) { 65 if (object is IOSink) {
65 try { 66 try {
66 if (object._sink.target is _FileStreamConsumer) { 67 if (object._target is _FileStreamConsumer) {
67 return StdioType.FILE; 68 return StdioType.FILE;
68 } 69 }
69 } catch (e) { 70 } catch (e) {
70 // Only the interface implemented, _sink not available. 71 // Only the interface implemented, _sink not available.
71 } 72 }
72 } 73 }
73 return StdioType.OTHER; 74 return StdioType.OTHER;
74 } 75 }
75 76
76 77
77 class _StdIOUtils { 78 class _StdIOUtils {
78 external static IOSink _getStdioOutputStream(int fd); 79 external static IOSink _getStdioOutputStream(int fd);
79 external static Stream<List<int>> _getStdioInputStream(); 80 external static Stream<List<int>> _getStdioInputStream();
80 external static int _socketType(nativeSocket); 81 external static int _socketType(nativeSocket);
81 } 82 }
OLDNEW
« no previous file with comments | « runtime/bin/stdio_patch.dart ('k') | tests/standalone/io/dart_std_io_pipe_script.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698