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

Unified Diff: base/sys_info_posix.cc

Issue 2764593002: Getting OS version numbers for Linux. (Closed)
Patch Set: Fixing build Created 3 years, 9 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 | « base/sys_info.h ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/sys_info_posix.cc
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc
index f480055cc4b472304b51e1c8f5c9d6246b81cbce..c4c07d07da20ecff9e2b12bd676c8c00c8156190 100644
--- a/base/sys_info_posix.cc
+++ b/base/sys_info_posix.cc
@@ -183,6 +183,30 @@ std::string SysInfo::OperatingSystemVersion() {
}
#endif
+#if !defined(OS_MACOSX) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
+// static
+void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version,
+ int32_t* minor_version,
+ int32_t* bugfix_version) {
+ struct utsname info;
+ if (uname(&info) < 0) {
+ NOTREACHED();
+ *major_version = 0;
+ *minor_version = 0;
+ *bugfix_version = 0;
+ return;
+ }
+ int num_read = sscanf(info.release, "%d.%d.%d", major_version, minor_version,
+ bugfix_version);
+ if (num_read < 1)
+ *major_version = 0;
+ if (num_read < 2)
+ *minor_version = 0;
+ if (num_read < 3)
+ *bugfix_version = 0;
+}
+#endif
+
// static
std::string SysInfo::OperatingSystemArchitecture() {
struct utsname info;
« no previous file with comments | « base/sys_info.h ('k') | base/sys_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698