OLD | NEW |
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 /** | 7 /** |
8 * Information about the environment in which the current program is running. | 8 * Information about the environment in which the current program is running. |
9 * | 9 * |
10 * Platform provides information such as the operating system, | 10 * Platform provides information such as the operating system, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 */ | 67 */ |
68 class Platform { | 68 class Platform { |
69 static final _numberOfProcessors = _Platform.numberOfProcessors; | 69 static final _numberOfProcessors = _Platform.numberOfProcessors; |
70 static final _pathSeparator = _Platform.pathSeparator; | 70 static final _pathSeparator = _Platform.pathSeparator; |
71 static final _operatingSystem = _Platform.operatingSystem; | 71 static final _operatingSystem = _Platform.operatingSystem; |
72 static final _localHostname = _Platform.localHostname; | 72 static final _localHostname = _Platform.localHostname; |
73 static final _version = _Platform.version; | 73 static final _version = _Platform.version; |
74 static final _localeName = _Platform.localeName; | 74 static final _localeName = _Platform.localeName; |
75 | 75 |
76 /** | 76 /** |
77 * Get the number of processors of the machine. | 77 * The number of individual execution units of the machine. |
78 */ | 78 */ |
79 static int get numberOfProcessors => _numberOfProcessors; | 79 static int get numberOfProcessors => _numberOfProcessors; |
80 | 80 |
81 /** | 81 /** |
82 * Get the path separator used by the operating system to separate | 82 * The path separator used by the operating system to separate |
83 * components in file paths. | 83 * components in file paths. |
84 */ | 84 */ |
85 static String get pathSeparator => _pathSeparator; | 85 static String get pathSeparator => _pathSeparator; |
86 | 86 |
87 /** | 87 /** |
88 * Get the name of the current locale. | 88 * Get the name of the current locale. |
89 */ | 89 */ |
90 static String get localeName => _localeName; | 90 static String get localeName => _localeName; |
91 | 91 |
92 /** | 92 /** |
93 * Get a string (`linux`, `macos`, `windows`, `android`, or `ios`) | 93 * A string representing the operating system or platform. |
94 * representing the operating system. | |
95 */ | 94 */ |
96 static String get operatingSystem => _operatingSystem; | 95 static String get operatingSystem => _operatingSystem; |
97 | 96 |
98 /** | 97 /** |
99 * Get the local hostname for the system. | 98 * The local hostname for the system. |
100 */ | 99 */ |
101 static String get localHostname => _localHostname; | 100 static String get localHostname => _localHostname; |
102 | 101 |
103 /** | 102 /** |
104 * Returns true if the operating system is Linux. | 103 * Whether the operating system is a version of |
| 104 * [Linux](https://en.wikipedia.org/wiki/Linux). |
| 105 * |
| 106 * This value is `false` if the operating system is a specialized |
| 107 * version of Linux that identifies itself by a different name, |
| 108 * for example Android (see [isAndroid]). |
105 */ | 109 */ |
106 static final bool isLinux = (_operatingSystem == "linux"); | 110 static final bool isLinux = (_operatingSystem == "linux"); |
107 | 111 |
108 /** | 112 /** |
109 * Returns true if the operating system is OS X. | 113 * Whether the operating system is a version of |
| 114 * [macOS](https://en.wikipedia.org/wiki/MacOS). |
110 */ | 115 */ |
111 static final bool isMacOS = (_operatingSystem == "macos"); | 116 static final bool isMacOS = (_operatingSystem == "macos"); |
112 | 117 |
113 /** | 118 /** |
114 * Returns true if the operating system is Windows. | 119 * Whether the operating system is a version of |
| 120 * [Microsoft Windows](https://en.wikipedia.org/wiki/Microsoft_Windows). |
115 */ | 121 */ |
116 static final bool isWindows = (_operatingSystem == "windows"); | 122 static final bool isWindows = (_operatingSystem == "windows"); |
117 | 123 |
118 /** | 124 /** |
119 * Returns true if the operating system is Android. | 125 * Whether the operating system is a version of |
| 126 * [Android](https://en.wikipedia.org/wiki/Android_%28operating_system%29). |
120 */ | 127 */ |
121 static final bool isAndroid = (_operatingSystem == "android"); | 128 static final bool isAndroid = (_operatingSystem == "android"); |
122 | 129 |
123 /** | 130 /** |
124 * Returns true if the operating system is iOS. | 131 * Whether the operating system is a version of |
| 132 * [iOS](https://en.wikipedia.org/wiki/IOS). |
125 */ | 133 */ |
126 static final bool isIOS = (_operatingSystem == "ios"); | 134 static final bool isIOS = (_operatingSystem == "ios"); |
127 | 135 |
128 /** | 136 /** |
129 * Returns true if the operating system is Fuchsia | 137 * Whether the operating system is a version of |
| 138 * [Fuchsia](https://en.wikipedia.org/wiki/Google_Fuchsia). |
130 */ | 139 */ |
131 static final bool isFuchsia = (_operatingSystem == "fuchsia"); | 140 static final bool isFuchsia = (_operatingSystem == "fuchsia"); |
132 | 141 |
133 /** | 142 /** |
134 * Get the environment for this process. | 143 * The environment for this process as a map from string key to string value. |
135 * | 144 * |
136 * The returned environment is an unmodifiable map which content is | 145 * The map is unmodifiable, |
137 * retrieved from the operating system on its first use. | 146 * and its content is retrieved from the operating system on its first use. |
138 * | 147 * |
139 * Environment variables on Windows are case-insensitive. The map | 148 * Environment variables on Windows are case-insensitive, |
140 * returned on Windows is therefore case-insensitive and will convert | 149 * so on Windows the map is case-insensitive and will convert |
141 * all keys to upper case. On other platforms the returned map is | 150 * all keys to upper case. |
142 * a standard case-sensitive map. | 151 * On other platforms, keys can be distinguished by case. |
143 */ | 152 */ |
144 static Map<String, String> get environment => _Platform.environment; | 153 static Map<String, String> get environment => _Platform.environment; |
145 | 154 |
146 /** | 155 /** |
147 * Returns the path of the executable used to run the script in this | 156 * The path of the executable used to run the script in this isolate. |
148 * isolate. | |
149 * | 157 * |
150 * The path returned is the literal path used to run the script. This | 158 * The literal path used to identify the script. |
151 * path might be relative or just be a name from which the executable | 159 * This path might be relative or just be a name from which the executable |
152 * was found by searching the `PATH`. | 160 * was found by searching the system path. |
153 * | 161 * |
154 * To get the absolute path to the resolved executable use | 162 * Use [resolvedExecutable] to get an absolute path to the executable. |
155 * [resolvedExecutable]. | |
156 */ | 163 */ |
157 static String get executable => _Platform.executable; | 164 static String get executable => _Platform.executable; |
158 | 165 |
159 /** | 166 /** |
160 * Returns the path of the executable used to run the script in this | 167 * The path of the executable used to run the script in this |
161 * isolate after it has been resolved by the OS. | 168 * isolate after it has been resolved by the OS. |
162 * | 169 * |
163 * This is the absolute path, with all symlinks resolved, to the | 170 * This is the absolute path, with all symlinks resolved, to the |
164 * executable used to run the script. | 171 * executable used to run the script. |
165 */ | 172 */ |
166 static String get resolvedExecutable => _Platform.resolvedExecutable; | 173 static String get resolvedExecutable => _Platform.resolvedExecutable; |
167 | 174 |
168 /** | 175 /** |
169 * Returns the absolute URI of the script being run in this | 176 * The absolute URI of the script being run in this isolate. |
170 * isolate. | |
171 * | 177 * |
172 * If the script argument on the command line is relative, | 178 * If the script argument on the command line is relative, |
173 * it is resolved to an absolute URI before fetching the script, and | 179 * it is resolved to an absolute URI before fetching the script, and |
174 * this absolute URI is returned. | 180 * that absolute URI is returned. |
175 * | 181 * |
176 * URI resolution only does string manipulation on the script path, and this | 182 * URI resolution only does string manipulation on the script path, and this |
177 * may be different from the file system's path resolution behavior. For | 183 * may be different from the file system's path resolution behavior. For |
178 * example, a symbolic link immediately followed by '..' will not be | 184 * example, a symbolic link immediately followed by '..' will not be |
179 * looked up. | 185 * looked up. |
180 * | 186 * |
181 * If the executable environment does not support [script] an empty | 187 * If the executable environment does not support [script], |
182 * [Uri] is returned. | 188 * the URI is empty. |
183 */ | 189 */ |
184 static Uri get script => _Platform.script; | 190 static Uri get script => _Platform.script; |
185 | 191 |
186 /** | 192 /** |
187 * Returns the flags passed to the executable used to run the script in this | 193 * The flags passed to the executable used to run the script in this isolate. |
188 * isolate. These are the command-line flags between the executable name | 194 * |
189 * and the script name. Each fetch of executableArguments returns a new | 195 * These are the command-line flags to the executable that precedes |
190 * List, containing the flags passed to the executable. | 196 * the script name. |
| 197 * Provides a new list every time the value is read. |
191 */ | 198 */ |
192 static List<String> get executableArguments => _Platform.executableArguments; | 199 static List<String> get executableArguments => _Platform.executableArguments; |
193 | 200 |
194 /** | 201 /** |
195 * Returns the value of the `--package-root` flag passed to the executable | 202 * The `--package-root` flag passed to the executable used to run the script |
196 * used to run the script in this isolate. This is the directory in which | 203 * in this isolate. |
197 * Dart packages are looked up. | |
198 * | 204 * |
199 * If there is no `--package-root` flag, `null` is returned. | 205 * If present, it specifies the directory where Dart packages are looked up. |
| 206 * |
| 207 * Is `null` if there is no `--package-root` flag. |
200 */ | 208 */ |
201 static String get packageRoot => _Platform.packageRoot; | 209 static String get packageRoot => _Platform.packageRoot; |
202 | 210 |
203 /** | 211 /** |
204 * Returns the value of the `--packages` flag passed to the executable | 212 * The `--packages` flag passed to the executable used to run the script |
205 * used to run the script in this isolate. This is the configuration which | 213 * in this isolate. |
206 * specifies how Dart packages are looked up. | 214 * |
207 * | 215 * If present, it specifies a file describing how Dart packages are looked up. |
208 * If there is no `--packages` flag, `null` is returned. | 216 * |
209 */ | 217 * Is `null` if there is no `--packages` flag. |
| 218 */ |
210 static String get packageConfig => _Platform.packageConfig; | 219 static String get packageConfig => _Platform.packageConfig; |
211 | 220 |
212 /** | 221 /** |
213 * Returns the version of the current Dart runtime. | 222 * The version of the current Dart runtime. |
214 * | 223 * |
215 * The returned `String` is formatted as the | 224 * The value is a [semantic versioning](http://semver.org) |
216 * [semver](http://semver.org) version string of the current dart | 225 * string representing the version of the current Dart runtime, |
217 * runtime, possibly followed by whitespace and other version and | 226 * possibly followed by whitespace and other version and |
218 * build details. | 227 * build details. |
219 */ | 228 */ |
220 static String get version => _version; | 229 static String get version => _version; |
221 } | 230 } |
OLD | NEW |