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

Unified Diff: runtime/bin/platform_linux.cc

Issue 3006873002: [dart:io] Adds Platform.operatingSystemVersion (Closed)
Patch Set: Updated CHANGELOG Created 3 years, 3 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_fuchsia.cc ('k') | runtime/bin/platform_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/platform_linux.cc
diff --git a/runtime/bin/platform_linux.cc b/runtime/bin/platform_linux.cc
index a085dff1773d4cdf9e993ce608a01fe85308671e..e681f034b89ac82a1b457fdca276d20dd009d357 100644
--- a/runtime/bin/platform_linux.cc
+++ b/runtime/bin/platform_linux.cc
@@ -7,9 +7,10 @@
#include "bin/platform.h"
-#include <signal.h> // NOLINT
-#include <string.h> // NOLINT
-#include <unistd.h> // NOLINT
+#include <signal.h> // NOLINT
+#include <string.h> // NOLINT
+#include <sys/utsname.h> // NOLINT
+#include <unistd.h> // NOLINT
#include "bin/fdutils.h"
#include "bin/file.h"
@@ -72,6 +73,28 @@ const char* Platform::OperatingSystem() {
return "linux";
}
+const char* Platform::OperatingSystemVersion() {
+ struct utsname info;
+ int ret = uname(&info);
+ if (ret != 0) {
+ return NULL;
+ }
+ const char* kFormat = "%s %s %s";
+ int len =
+ snprintf(NULL, 0, kFormat, info.sysname, info.release, info.version);
+ if (len <= 0) {
+ return NULL;
+ }
+ char* result = DartUtils::ScopedCString(len + 1);
+ ASSERT(result != NULL);
+ len = snprintf(result, len + 1, kFormat, info.sysname, info.release,
+ info.version);
+ if (len <= 0) {
+ return NULL;
+ }
+ return result;
+}
+
const char* Platform::LibraryPrefix() {
return "lib";
}
« no previous file with comments | « runtime/bin/platform_fuchsia.cc ('k') | runtime/bin/platform_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698