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

Unified Diff: runtime/bin/platform_macos.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_linux.cc ('k') | runtime/bin/platform_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/platform_macos.cc
diff --git a/runtime/bin/platform_macos.cc b/runtime/bin/platform_macos.cc
index b02bca7554f31e8de0237fd29de4f9a8f97a0815..e563788ceb3e22cab73e623d54dbbd4c08b72ac2 100644
--- a/runtime/bin/platform_macos.cc
+++ b/runtime/bin/platform_macos.cc
@@ -13,11 +13,12 @@
#include <crt_externs.h> // NOLINT
#endif // !HOST_OS_IOS
#include <mach-o/dyld.h>
-#include <signal.h> // NOLINT
-#include <string.h> // NOLINT
-#include <sys/sysctl.h> // NOLINT
-#include <sys/types.h> // NOLINT
-#include <unistd.h> // NOLINT
+#include <signal.h> // NOLINT
+#include <string.h> // NOLINT
+#include <sys/sysctl.h> // NOLINT
+#include <sys/types.h> // NOLINT
+#include <sys/utsname.h> // NOLINT
+#include <unistd.h> // NOLINT
#include "bin/fdutils.h"
#include "bin/file.h"
@@ -90,6 +91,28 @@ const char* Platform::OperatingSystem() {
#endif
}
+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_linux.cc ('k') | runtime/bin/platform_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698