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

Unified Diff: runtime/bin/stdio_patch.dart

Issue 11553020: Fix unresolved classes issues in dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « no previous file | runtime/lib/byte_array.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/stdio_patch.dart
diff --git a/runtime/bin/stdio_patch.dart b/runtime/bin/stdio_patch.dart
index bcdc671aea511af35ac17df1a4bbad222ffde869..5dd5d87c2a8e4c1111c911a078f41ea4e65cc371 100644
--- a/runtime/bin/stdio_patch.dart
+++ b/runtime/bin/stdio_patch.dart
@@ -3,8 +3,39 @@
// BSD-style license that can be found in the LICENSE file.
patch class _StdIOUtils {
- /* patch */ static _getStdioHandle(Socket socket, int num)
- native "Socket_GetStdioHandle";
- /* patch */ static _getStdioHandleType(int num)
- native "File_GetStdioHandleType";
+ static InputStream _getStdioInputStream() {
+ switch (_getStdioHandleType(0)) {
+ case _STDIO_HANDLE_TYPE_TERMINAL:
+ case _STDIO_HANDLE_TYPE_PIPE:
+ case _STDIO_HANDLE_TYPE_SOCKET:
+ Socket s = new _Socket._internalReadOnly();
+ _getStdioHandle(s, 0);
+ s._closed = false;
+ return s.inputStream;
+ case _STDIO_HANDLE_TYPE_FILE:
+ return new _FileInputStream.fromStdio(0);
+ default:
+ throw new FileIOException("Unsupported stdin type");
+ }
+ }
+
+ static OutputStream _getStdioOutputStream(int fd) {
+ assert(fd == 1 || fd == 2);
+ switch (_getStdioHandleType(fd)) {
+ case _STDIO_HANDLE_TYPE_TERMINAL:
+ case _STDIO_HANDLE_TYPE_PIPE:
+ case _STDIO_HANDLE_TYPE_SOCKET:
+ Socket s = new _Socket._internalWriteOnly();
+ _getStdioHandle(s, fd);
+ s._closed = false;
+ return s.outputStream;
+ case _STDIO_HANDLE_TYPE_FILE:
+ return new _FileOutputStream.fromStdio(fd);
+ default:
+ throw new FileIOException("Unsupported stdin type");
+ }
+ }
}
+
+_getStdioHandle(Socket socket, int num) native "Socket_GetStdioHandle";
+_getStdioHandleType(int num) native "File_GetStdioHandleType";
« no previous file with comments | « no previous file | runtime/lib/byte_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698