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

Unified Diff: runtime/bin/socket_macos.cc

Issue 11773041: Add function for finding what a InputStream or OutputStream is attached to (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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/socket_linux.cc ('k') | runtime/bin/socket_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_macos.cc
diff --git a/runtime/bin/socket_macos.cc b/runtime/bin/socket_macos.cc
index 275169ff2d4d191ae7921327303448573df65349..07a9eddd6a4ae3fd9b50f93a4ddd98c3e3310073 100644
--- a/runtime/bin/socket_macos.cc
+++ b/runtime/bin/socket_macos.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2013, 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.
@@ -6,9 +6,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/stat.h>
#include <unistd.h>
#include "bin/fdutils.h"
+#include "bin/file.h"
#include "bin/log.h"
#include "bin/socket.h"
@@ -135,6 +137,17 @@ void Socket::GetError(intptr_t fd, OSError* os_error) {
}
+int Socket::GetType(intptr_t fd) {
+ struct stat buf;
+ if (isatty(fd)) return File::kTerminal;
+ int result = fstat(fd, &buf);
+ if (result == -1) return -1;
+ if (S_ISFIFO(buf.st_mode)) return File::kPipe;
+ if (S_ISREG(buf.st_mode)) return File::kFile;
+ return File::kOther;
+}
+
+
intptr_t Socket::GetStdioHandle(int num) {
return static_cast<intptr_t>(num);
}
« no previous file with comments | « runtime/bin/socket_linux.cc ('k') | runtime/bin/socket_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698