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

Unified Diff: sdk/lib/io/platform.dart

Issue 17175007: dart:io | Add cache and getters to Platform (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | « no previous file | tests/standalone/io/platform_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/platform.dart
diff --git a/sdk/lib/io/platform.dart b/sdk/lib/io/platform.dart
index 156238a2a0df14a722d41a83df73acaaa7d85d88..bdb56b856d9d90c70dc13d89b6df548b96762640 100644
--- a/sdk/lib/io/platform.dart
+++ b/sdk/lib/io/platform.dart
@@ -9,27 +9,52 @@ part of dart.io;
* system.
*/
class Platform {
+ static final _numberOfProcessors = _Platform.numberOfProcessors;
+ static final _pathSeparator = _Platform.pathSeparator;
+ static final _operatingSystem = _Platform.operatingSystem;
+ static final _localHostname = _Platform.localHostname;
+
/**
* Get the number of processors of the machine.
*/
- static int get numberOfProcessors => _Platform.numberOfProcessors;
+ static int get numberOfProcessors => _numberOfProcessors;
/**
* Get the path separator used by the operating system to separate
* components in file paths.
*/
- static String get pathSeparator => _Platform.pathSeparator;
+ static String get pathSeparator => _pathSeparator;
/**
- * Get a string ('macos', 'windows', 'linux') representing the
- * operating system.
+ * Get a string (`linux`, `macos`, `windows` or `android`)
+ * representing the operating system.
*/
- static String get operatingSystem => _Platform.operatingSystem;
+ static String get operatingSystem => _operatingSystem;
/**
* Get the local hostname for the system.
*/
- static String get localHostname => _Platform.localHostname;
+ static String get localHostname => _localHostname;
+
+ /**
+ * Returns true if the operating system is Linux.
+ */
+ static bool get isLinux => _operatingSystem == "linux";
+
+ /**
+ * Returns true if the operating system is Mac OS.
+ */
+ static bool get isMacOS => _operatingSystem == "macos";
+
+ /**
+ * Returns true if the operating system is Windows.
+ */
+ static bool get isWindows => _operatingSystem == "windows";
+
+ /**
+ * Returns true if the operating system is Android.
+ */
+ static bool get isAndroid => _operatingSystem == "android";
/**
* Get the environment for this process.
« no previous file with comments | « no previous file | tests/standalone/io/platform_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698