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

Unified Diff: sdk/lib/io/stdio.dart

Issue 11773041: Add function for finding what a InputStream or OutputStream is attached to (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/stdio_patch.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/stdio.dart
diff --git a/sdk/lib/io/stdio.dart b/sdk/lib/io/stdio.dart
index fc893bf125851f61ca24a3bb2732aa3cf1356b70..ae664887343106d5dd94409a279093386c0f7999 100644
--- a/sdk/lib/io/stdio.dart
+++ b/sdk/lib/io/stdio.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -11,6 +11,16 @@ const int _STDIO_HANDLE_TYPE_SOCKET = 3;
const int _STDIO_HANDLE_TYPE_OTHER = -1;
+class StdioType {
+ static const StdioType TERMINAL = const StdioType._("terminal");
+ static const StdioType PIPE = const StdioType._("pipe");
+ static const StdioType FILE = const StdioType._("file");
+ static const StdioType OTHER = const StdioType._("other");
+ const StdioType._(String this.name);
+ final String name;
+}
+
+
InputStream _stdin;
OutputStream _stdout;
OutputStream _stderr;
@@ -40,7 +50,24 @@ OutputStream get stderr {
}
+StdioType stdioType(object) {
+ if (object is _FileOutputStream || object is _FileInputStream) {
+ return StdioType.FILE;
+ }
+ if (object is !_SocketOutputStream && object is !_SocketInputStream) {
+ return StdioType.OTHER;
+ }
+ switch (_StdIOUtils._socketType(object._socket)) {
+ case _STDIO_HANDLE_TYPE_TERMINAL: return StdioType.TERMINAL;
+ case _STDIO_HANDLE_TYPE_PIPE: return StdioType.PIPE;
+ case _STDIO_HANDLE_TYPE_FILE: return StdioType.FILE;
+ default: return StdioType.OTHER;
+ }
+}
+
+
class _StdIOUtils {
external static OutputStream _getStdioOutputStream(int fd);
external static InputStream _getStdioInputStream();
+ external static int _socketType(Socket socket);
}
« no previous file with comments | « runtime/bin/stdio_patch.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698