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

Unified Diff: runtime/bin/file_impl.dart

Issue 9360040: Handle stdio redirection in standalone VM (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert test change Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_impl.dart
diff --git a/runtime/bin/file_impl.dart b/runtime/bin/file_impl.dart
index d847acb9b8df72debe6f7411b6add5c47c368de4..771a9b9e85692284c7a93a1b9e853fd2115f5e79 100644
--- a/runtime/bin/file_impl.dart
+++ b/runtime/bin/file_impl.dart
@@ -10,6 +10,14 @@ class _FileInputStream extends _BaseDataInputStream implements InputStream {
_checkScheduleCallbacks();
}
+ _FileInputStream.fromStdio(int fd) {
+ assert(fd == 0);
+ _file = _File._openStdioSync(fd);
+ _length = _file.lengthSync();
+ _streamMarkedClosed = true;
+ _checkScheduleCallbacks();
+ }
+
int available() {
return _closed ? 0 : _length - _file.positionSync();
}
@@ -53,6 +61,11 @@ class _FileOutputStream implements OutputStream {
_file = file.openSync(mode);
}
+ _FileOutputStream.fromStdio(int fd) {
+ assert(1 <= fd && fd <= 2);
+ _file = _File._openStdioSync(fd);
+ }
+
bool write(List<int> buffer, [bool copyBuffer = false]) {
return _write(buffer, 0, buffer.length);
}
@@ -452,6 +465,7 @@ class _FileUtils {
static bool truncate(int id, int length) native "File_Truncate";
static int length(int id) native "File_Length";
static int flush(int id) native "File_Flush";
+ static int openStdio(int fd) native "File_OpenStdio";
static int checkedOpen(String name, int mode) {
if (name is !String || mode is !int) return 0;
@@ -618,6 +632,14 @@ class _File implements File {
return new _RandomAccessFile(id, _name);
}
+ static RandomAccessFile _openStdioSync(int fd) {
+ var id = _FileUtils.openStdio(fd);
+ if (id == 0) {
+ throw new FileIOException("Cannot open stdio file for: $fd");
+ }
+ return new _RandomAccessFile(id, "");
+ }
+
void fullPath() {
_asyncUsed = true;
var handleFullPathResult = (result, ignored) {
« no previous file with comments | « runtime/bin/file.cc ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698