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

Unified Diff: runtime/bin/platform_win.cc

Issue 10050011: Add member localHostname() to the Dart IO Platform class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Using static bool to control initialization. Created 8 years, 8 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/platform_macos.cc ('k') | tests/standalone/src/io/PlatformTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/platform_win.cc
diff --git a/runtime/bin/platform_win.cc b/runtime/bin/platform_win.cc
index e1f9ced1f427cbc1c7f782303cebaf8d1bc3eede..115cdf097e7632178343e4f3671fa42c676270f7 100644
--- a/runtime/bin/platform_win.cc
+++ b/runtime/bin/platform_win.cc
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
#include "bin/platform.h"
+#include "bin/socket.h"
bool Platform::Initialize() {
@@ -23,6 +24,17 @@ const char* Platform::OperatingSystem() {
}
+bool Platform::LocalHostname(char *buffer, intptr_t buffer_length) {
+ static bool socketInitialized = false;
+ if (!socketInitialized) {
+ // Initialize Socket for gethostname.
+ if (!Socket::Initialize()) return false;
+ socketInitialized = true;
+ }
+ return gethostname(buffer, buffer_length) == 0;
+}
+
+
char* Platform::StrError(int error_code) {
static const int kBufferSize = 1024;
char* error = static_cast<char*>(malloc(kBufferSize));
« no previous file with comments | « runtime/bin/platform_macos.cc ('k') | tests/standalone/src/io/PlatformTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698