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

Unified Diff: runtime/bin/stdio.dart

Issue 11337019: Use patching for dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 8 years, 2 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
Index: runtime/bin/stdio.dart
diff --git a/runtime/bin/stdio.dart b/runtime/bin/stdio.dart
deleted file mode 100644
index 727c3754e780891713138b7a1a8188d74bd49d16..0000000000000000000000000000000000000000
--- a/runtime/bin/stdio.dart
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2012, 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.
-
-const int _STDIO_HANDLE_TYPE_TERMINAL = 0;
-const int _STDIO_HANDLE_TYPE_PIPE = 1;
-const int _STDIO_HANDLE_TYPE_FILE = 2;
-const int _STDIO_HANDLE_TYPE_SOCKET = 3;
-const int _STDIO_HANDLE_TYPE_OTHER = -1;
-
-
-InputStream _stdin;
-OutputStream _stdout;
-OutputStream _stderr;
-
-
-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");
- }
-}
-
-
-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");
- }
-}
-
-
-InputStream get stdin {
- if (_stdin == null) {
- _stdin = _getStdioInputStream();
- }
- return _stdin;
-}
-
-
-OutputStream get stdout {
- if (_stdout == null) {
- _stdout = _getStdioOutputStream(1);
- }
- return _stdout;
-}
-
-
-OutputStream get stderr {
- if (_stderr == null) {
- _stderr = _getStdioOutputStream(2);
- }
- return _stderr;
-}
-
-_getStdioHandle(Socket socket, int num) native "Socket_GetStdioHandle";
-_getStdioHandleType(int num) native "File_GetStdioHandleType";

Powered by Google App Engine
This is Rietveld 408576698