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

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

Issue 159713011: class-level docs for several dart:io classes (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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 /** 7 /**
8 * The [Platform] class exposes details of the machine and operating 8 * Information about the environment in which the current program is running.
9 * system. 9 *
10 * Platform provides information such as the operating system,
11 * the hostname of the computer, the value of environment variables,
12 * the path to the running program,
13 * and so on.
14 *
15 * ## Get the URI to the current program
Søren Gjesse 2014/02/12 13:16:35 program -> Dart script
mem 2014/02/12 19:17:07 Done.
16 *
17 * Use the [script] getter to get the URI to the currently running program.
Søren Gjesse 2014/02/12 13:16:35 ditto.
mem 2014/02/12 19:17:07 Done.
18 *
19 * import 'dart:io' show Platform;
20 *
21 * void main() {
22 * // Get the URI of the script being run.
23 * var uri = Platform.script;
24 * // Convert the URI to a path.
25 * var path = uri.toFilePath();
26 * }
27 *
28 * ## Get the value of an environment variable
29 *
30 * The [environment] getter returns a the names and values of environment
31 * variables in a [Map] that contains key-value pairs of strings. The Map is
32 * unmodifiable. This sample shows how to get the value of the `PATH`
33 * environment variable.
34 *
35 * import 'dart:io' show Platform;
36 *
37 * void main() {
38 * Map<String, String> envVars = Platform.environment;
39 * print(envVars['PATH']);
40 * }
41 *
42 * ## Determine the OS
43 *
44 * You can get the name of the operating system as a string with the
45 * [operatingSystem] getter. You can also use one of the static boolean
46 * getters: [isMacOS], [isLinux], and so on.
Søren Gjesse 2014/02/12 13:16:35 so on -> isWindows (there are only these three.
mem 2014/02/12 19:17:07 Done.
47 *
48 * import 'dart:io' show Platform, stdout;
49 *
50 * void main() {
51 * // Get the operating system as a string.
52 * String os = Platform.operatingSystem;
53 * // Or, use a predicate getter.
54 * if (Platform.isMacOS) {
55 * Print('is a Mac');
56 * } else {
57 * print('is not a Mac');
58 * }
59 * }
60 *
61 * ## Other resources
62 *
63 * [Dart by Example](https://www.dartlang.org/dart-by-example/#dart-io-and-comma nd-line-apps)
64 * provides additional task-oriented code samples that show how to use
65 * various API from the [dart:io] library.
10 */ 66 */
11 class Platform { 67 class Platform {
12 static final _numberOfProcessors = _Platform.numberOfProcessors; 68 static final _numberOfProcessors = _Platform.numberOfProcessors;
13 static final _pathSeparator = _Platform.pathSeparator; 69 static final _pathSeparator = _Platform.pathSeparator;
14 static final _operatingSystem = _Platform.operatingSystem; 70 static final _operatingSystem = _Platform.operatingSystem;
15 static final _localHostname = _Platform.localHostname; 71 static final _localHostname = _Platform.localHostname;
16 static final _version = _Platform.version; 72 static final _version = _Platform.version;
17 73
18 // This script singleton is written to by the embedder if applicable. 74 // This script singleton is written to by the embedder if applicable.
19 static String _nativeScript = ''; 75 static String _nativeScript = '';
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 static bool get isWindows => _operatingSystem == "windows"; 112 static bool get isWindows => _operatingSystem == "windows";
57 113
58 /** 114 /**
59 * Returns true if the operating system is Android. 115 * Returns true if the operating system is Android.
60 */ 116 */
61 static bool get isAndroid => _operatingSystem == "android"; 117 static bool get isAndroid => _operatingSystem == "android";
62 118
63 /** 119 /**
64 * Get the environment for this process. 120 * Get the environment for this process.
65 * 121 *
66 * The returned environment is a unmodifiable map which content is 122 * The returned environment is an unmodifiable map which content is
67 * retrieved from the operating system on its first use. 123 * retrieved from the operating system on its first use.
68 * 124 *
69 * Environment variables on Windows are case-insensitive. The map 125 * Environment variables on Windows are case-insensitive. The map
70 * returned on Windows is therefore case-insensitive and will convert 126 * returned on Windows is therefore case-insensitive and will convert
71 * all keys to upper case. On other platforms the returned map is 127 * all keys to upper case. On other platforms the returned map is
72 * a standard case-sensitive map. 128 * a standard case-sensitive map.
73 */ 129 */
74 static Map<String, String> get environment => _Platform.environment; 130 static Map<String, String> get environment => _Platform.environment;
75 131
76 /** 132 /**
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 * 171 *
116 * If there is no --package-root flag, then the empty string is returned. 172 * If there is no --package-root flag, then the empty string is returned.
117 */ 173 */
118 static String get packageRoot => _Platform.packageRoot; 174 static String get packageRoot => _Platform.packageRoot;
119 175
120 /** 176 /**
121 * Returns the version of the current Dart runtime. 177 * Returns the version of the current Dart runtime.
122 */ 178 */
123 static String get version => _version; 179 static String get version => _version;
124 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698