mirror of
https://github.com/dart-lang/sdk
synced 2024-09-22 20:34:31 +00:00
887c8e7596
The getters for executable, script and version are now statics on Platform. I kept them on Options for now, but updated most tests to use Platform. R=ajohnsen@google.com, floitsch@google.com, iposva@google.com BUG= Review URL: https://codereview.chromium.org//17406010 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@24401 260f80e4-7a28-3924-810f-c04153c831b5
99 lines
2.8 KiB
Dart
99 lines
2.8 KiB
Dart
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
part of dart.io;
|
|
|
|
/**
|
|
* The [Platform] class exposes details of the machine and operating
|
|
* system.
|
|
*/
|
|
class Platform {
|
|
static final _numberOfProcessors = _Platform.numberOfProcessors;
|
|
static final _pathSeparator = _Platform.pathSeparator;
|
|
static final _operatingSystem = _Platform.operatingSystem;
|
|
static final _localHostname = _Platform.localHostname;
|
|
static final _version = _Platform.version;
|
|
|
|
// This executable singleton is written to by the embedder if applicable.
|
|
static String _nativeExecutable = '';
|
|
|
|
// This script singleton is written to by the embedder if applicable.
|
|
static String _nativeScript = '';
|
|
|
|
/**
|
|
* Get the number of processors of the machine.
|
|
*/
|
|
static int get numberOfProcessors => _numberOfProcessors;
|
|
|
|
/**
|
|
* Get the path separator used by the operating system to separate
|
|
* components in file paths.
|
|
*/
|
|
static String get pathSeparator => _pathSeparator;
|
|
|
|
/**
|
|
* Get a string (`linux`, `macos`, `windows` or `android`)
|
|
* representing the operating system.
|
|
*/
|
|
static String get operatingSystem => _operatingSystem;
|
|
|
|
/**
|
|
* Get the local hostname for the system.
|
|
*/
|
|
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.
|
|
*
|
|
* Environment variables on Windows are case-insensitive. The map
|
|
* returned on Windows is therefore case-insensitive and will convert
|
|
* all keys to upper case. On other platforms the returned map is
|
|
* a standard case-sensitive map.
|
|
*/
|
|
static Map<String, String> get environment => _Platform.environment;
|
|
|
|
/**
|
|
* Returns the path of the executable used to run the script in this
|
|
* isolate.
|
|
*
|
|
* If the execution environment does not support [executable] an empty
|
|
* string is returned.
|
|
*/
|
|
static String get executable => _nativeExecutable;
|
|
|
|
/**
|
|
* Returns the path of the script being run in this isolate.
|
|
*
|
|
* If the executable environment does not support [script] an empty
|
|
* string is returned.
|
|
*/
|
|
static String get script => _nativeScript;
|
|
|
|
|
|
/**
|
|
* Returns the version of the current Dart runtime.
|
|
*/
|
|
static String get version => _version;
|
|
}
|