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

Unified Diff: runtime/bin/file_linux.cc

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_impl.dart ('k') | runtime/bin/file_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_linux.cc
diff --git a/runtime/bin/file_linux.cc b/runtime/bin/file_linux.cc
index 4cafc5a1b5749c4dc68fa13001af5b3d80b7cb2f..e28c322982f320141657a44cd30a954c1f74fc0b 100644
--- a/runtime/bin/file_linux.cc
+++ b/runtime/bin/file_linux.cc
@@ -126,6 +126,12 @@ File* File::Open(const char* name, FileOpenMode mode) {
}
+File* File::OpenStdio(int fd) {
+ if (fd < 0 || 2 < fd) return NULL;
+ return new File(NULL, new FileHandle(fd));
+}
+
+
bool File::Exists(const char* name) {
struct stat st;
if (TEMP_FAILURE_RETRY(stat(name, &st)) == 0) {
@@ -179,3 +185,17 @@ const char* File::PathSeparator() {
const char* File::StringEscapedPathSeparator() {
return "/";
}
+
+
+File::StdioHandleType File::GetStdioHandleType(int fd) {
+ ASSERT(0 <= fd && fd <= 2);
+ struct stat buf;
+ int result = fstat(fd, &buf);
+ if (result == -1) {
+ FATAL2("Failed stat on file descriptor %d: %s", fd, strerror(errno));
+ }
+ if (S_ISCHR(buf.st_mode)) return kTerminal;
+ if (S_ISFIFO(buf.st_mode)) return kPipe;
+ if (S_ISREG(buf.st_mode)) return kFile;
+ return kOther;
+}
« no previous file with comments | « runtime/bin/file_impl.dart ('k') | runtime/bin/file_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698