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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « runtime/bin/platform_linux.cc ('k') | runtime/bin/platform_patch.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(HOST_OS_MACOS) 6 #if defined(HOST_OS_MACOS)
7 7
8 #include "bin/platform.h" 8 #include "bin/platform.h"
9 9
10 #include <CoreFoundation/CoreFoundation.h> 10 #include <CoreFoundation/CoreFoundation.h>
11 11
12 #if !HOST_OS_IOS 12 #if !HOST_OS_IOS
13 #include <crt_externs.h> // NOLINT 13 #include <crt_externs.h> // NOLINT
14 #endif // !HOST_OS_IOS 14 #endif // !HOST_OS_IOS
15 #include <mach-o/dyld.h> 15 #include <mach-o/dyld.h>
16 #include <signal.h> // NOLINT 16 #include <signal.h> // NOLINT
17 #include <string.h> // NOLINT 17 #include <string.h> // NOLINT
18 #include <sys/sysctl.h> // NOLINT 18 #include <sys/sysctl.h> // NOLINT
19 #include <sys/types.h> // NOLINT 19 #include <sys/types.h> // NOLINT
20 #include <unistd.h> // NOLINT 20 #include <sys/utsname.h> // NOLINT
21 #include <unistd.h> // NOLINT
21 22
22 #include "bin/fdutils.h" 23 #include "bin/fdutils.h"
23 #include "bin/file.h" 24 #include "bin/file.h"
24 25
25 namespace dart { 26 namespace dart {
26 namespace bin { 27 namespace bin {
27 28
28 const char* Platform::executable_name_ = NULL; 29 const char* Platform::executable_name_ = NULL;
29 char* Platform::resolved_executable_name_ = NULL; 30 char* Platform::resolved_executable_name_ = NULL;
30 int Platform::script_index_ = 1; 31 int Platform::script_index_ = 1;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 84 }
84 85
85 const char* Platform::OperatingSystem() { 86 const char* Platform::OperatingSystem() {
86 #if HOST_OS_IOS 87 #if HOST_OS_IOS
87 return "ios"; 88 return "ios";
88 #else 89 #else
89 return "macos"; 90 return "macos";
90 #endif 91 #endif
91 } 92 }
92 93
94 const char* Platform::OperatingSystemVersion() {
95 struct utsname info;
96 int ret = uname(&info);
97 if (ret != 0) {
98 return NULL;
99 }
100 const char* kFormat = "%s %s %s";
101 int len =
102 snprintf(NULL, 0, kFormat, info.sysname, info.release, info.version);
103 if (len <= 0) {
104 return NULL;
105 }
106 char* result = DartUtils::ScopedCString(len + 1);
107 ASSERT(result != NULL);
108 len = snprintf(result, len + 1, kFormat, info.sysname, info.release,
109 info.version);
110 if (len <= 0) {
111 return NULL;
112 }
113 return result;
114 }
115
93 const char* Platform::LibraryPrefix() { 116 const char* Platform::LibraryPrefix() {
94 return "lib"; 117 return "lib";
95 } 118 }
96 119
97 const char* Platform::LibraryExtension() { 120 const char* Platform::LibraryExtension() {
98 return "dylib"; 121 return "dylib";
99 } 122 }
100 123
101 static const char* GetLocaleName() { 124 static const char* GetLocaleName() {
102 CFLocaleRef locale = CFLocaleCopyCurrent(); 125 CFLocaleRef locale = CFLocaleCopyCurrent();
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 229 }
207 230
208 void Platform::Exit(int exit_code) { 231 void Platform::Exit(int exit_code) {
209 exit(exit_code); 232 exit(exit_code);
210 } 233 }
211 234
212 } // namespace bin 235 } // namespace bin
213 } // namespace dart 236 } // namespace dart
214 237
215 #endif // defined(HOST_OS_MACOS) 238 #endif // defined(HOST_OS_MACOS)
OLDNEW
« 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