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

Unified Diff: runtime/bin/file_macos.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_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file_macos.cc
diff --git a/runtime/bin/file_macos.cc b/runtime/bin/file_macos.cc
index d19045397fe5822c51d1faa2cbb7e05167239beb..352b9d140abe01a309dac4833ec15ef92a3e38ac 100644
--- a/runtime/bin/file_macos.cc
+++ b/runtime/bin/file_macos.cc
@@ -127,6 +127,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) {
@@ -186,3 +192,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_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698