| 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;
|
| +}
|
|
|