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

Side by Side Diff: sdk/lib/io/platform_impl.dart

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 | « sdk/lib/io/platform.dart ('k') | tests/standalone/io/platform_os_version_test.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 part of dart.io; 5 part of dart.io;
6 6
7 class _Platform { 7 class _Platform {
8 external static int _numberOfProcessors(); 8 external static int _numberOfProcessors();
9 external static String _pathSeparator(); 9 external static String _pathSeparator();
10 external static String _operatingSystem(); 10 external static String _operatingSystem();
11 external static _operatingSystemVersion();
11 external static _localHostname(); 12 external static _localHostname();
12 external static _executable(); 13 external static _executable();
13 external static _resolvedExecutable(); 14 external static _resolvedExecutable();
14 15
15 /** 16 /**
16 * Retrieve the entries of the process environment. 17 * Retrieve the entries of the process environment.
17 * 18 *
18 * The result is an [Iterable] of strings, where each string represents 19 * The result is an [Iterable] of strings, where each string represents
19 * an environment entry. 20 * an environment entry.
20 * 21 *
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 55
55 // Cache the OS environment. This can be an OSError instance if 56 // Cache the OS environment. This can be an OSError instance if
56 // retrieving the environment failed. 57 // retrieving the environment failed.
57 static var /*OSError|Map<String,String>*/ _environmentCache; 58 static var /*OSError|Map<String,String>*/ _environmentCache;
58 59
59 static int get numberOfProcessors => _numberOfProcessors(); 60 static int get numberOfProcessors => _numberOfProcessors();
60 static String get pathSeparator => _pathSeparator(); 61 static String get pathSeparator => _pathSeparator();
61 static String get operatingSystem => _operatingSystem(); 62 static String get operatingSystem => _operatingSystem();
62 static Uri get script => _script(); 63 static Uri get script => _script();
63 64
65 static String _cachedOSVersion;
66 static String get operatingSystemVersion {
67 if (_cachedOSVersion == null) {
68 var result = _operatingSystemVersion();
69 if (result is OSError) {
70 throw result;
71 }
72 _cachedOSVersion = result;
73 }
74 return _cachedOSVersion;
75 }
76
64 static String get localHostname { 77 static String get localHostname {
65 var result = _localHostname(); 78 var result = _localHostname();
66 if (result is OSError) { 79 if (result is OSError) {
67 throw result; 80 throw result;
68 } else {
69 return result;
70 } 81 }
82 return result;
71 } 83 }
72 84
73 static List<String> get executableArguments => _executableArguments(); 85 static List<String> get executableArguments => _executableArguments();
74 86
75 static Map<String, String> get environment { 87 static Map<String, String> get environment {
76 if (_environmentCache == null) { 88 if (_environmentCache == null) {
77 var env = _environment(); 89 var env = _environment();
78 if (env is! OSError) { 90 if (env is! OSError) {
79 var isWindows = operatingSystem == 'windows'; 91 var isWindows = operatingSystem == 'windows';
80 var result = isWindows 92 var result = isWindows
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 _map.forEach(f); 153 _map.forEach(f);
142 } 154 }
143 155
144 Iterable<String> get keys => _map.keys; 156 Iterable<String> get keys => _map.keys;
145 Iterable<V> get values => _map.values; 157 Iterable<V> get values => _map.values;
146 int get length => _map.length; 158 int get length => _map.length;
147 bool get isEmpty => _map.isEmpty; 159 bool get isEmpty => _map.isEmpty;
148 bool get isNotEmpty => _map.isNotEmpty; 160 bool get isNotEmpty => _map.isNotEmpty;
149 String toString() => _map.toString(); 161 String toString() => _map.toString();
150 } 162 }
OLDNEW
« no previous file with comments | « sdk/lib/io/platform.dart ('k') | tests/standalone/io/platform_os_version_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698