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

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

Issue 1307183002: Add access to the isolate package-root/package-map in Platform. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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
« sdk/lib/io/platform.dart ('K') | « sdk/lib/io/platform.dart ('k') | no next file » | 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 _localHostname(); 11 external static _localHostname();
12 external static _executable(); 12 external static _executable();
13 external static _resolvedExecutable(); 13 external static _resolvedExecutable();
14 /** 14 /**
15 * Retrieve the entries of the process environment. 15 * Retrieve the entries of the process environment.
16 * 16 *
17 * The result is an [Iterable] of strings, where each string represents 17 * The result is an [Iterable] of strings, where each string represents
18 * an environment entry. 18 * an environment entry.
19 * 19 *
20 * Environment entries should be strings containing 20 * Environment entries should be strings containing
21 * a non-empty name and a value separated by a '=' character. 21 * a non-empty name and a value separated by a '=' character.
22 * The name does not contain a '=' character, 22 * The name does not contain a '=' character,
23 * so the name is everything up to the first '=' character. 23 * so the name is everything up to the first '=' character.
24 * Values are everything after the first '=' charcacter. 24 * Values are everything after the first '=' character.
25 * A value may contain further '=' characters, and it may be empty. 25 * A value may contain further '=' characters, and it may be empty.
26 * 26 *
27 * Returns an [OSError] if retrieving the environment fails. 27 * Returns an [OSError] if retrieving the environment fails.
28 */ 28 */
29 external static _environment(); 29 external static _environment();
30 external static List<String> _executableArguments(); 30 external static List<String> _executableArguments();
31 external static String _packageRoot(); 31 external static String _packageRoot();
32 external static _packageResolution();
32 external static String _version(); 33 external static String _version();
33 34
34 static String executable = _executable(); 35 static String executable = _executable();
35 static String resolvedExecutable = _resolvedExecutable(); 36 static String resolvedExecutable = _resolvedExecutable();
36 static String packageRoot = _packageRoot(); 37 static String packageRoot = _packageRoot();
38 static var _resolution = () {
39 var res = _packageResolution();
40 // Do not give users access to the real map.
41 if (res is Map) res = new Map<String, Uri>.unmodifiable(res);
42 return res;
43 } ();
37 44
38 // Cache the OS environemnt. This can be an OSError instance if 45 static Uri get packageRootUri {
46 if (_resolution is Uri) return _resolution;
Ivan Posva 2015/08/26 04:29:36 I'll implement these without going through native
Lasse Reichstein Nielsen 2015/08/26 06:26:06 That's fine. I'll just add the interface for now.
47 return null;
48 }
49
50 static Map<String, Uri> get packageMap {
51 if (_resolution is Map) return _resolution;
52 if (_resolution == null) return const <String, Uri>{};
53 return null;
54 }
55
56 // Cache the OS environment. This can be an OSError instance if
39 // retrieving the environment failed. 57 // retrieving the environment failed.
40 static var _environmentCache; 58 static var _environmentCache;
41 59
42 static int get numberOfProcessors => _numberOfProcessors(); 60 static int get numberOfProcessors => _numberOfProcessors();
43 static String get pathSeparator => _pathSeparator(); 61 static String get pathSeparator => _pathSeparator();
44 static String get operatingSystem => _operatingSystem(); 62 static String get operatingSystem => _operatingSystem();
45 static Uri script; 63 static Uri script;
46 64
47 // This script singleton is written to by the embedder if applicable. 65 // This script singleton is written to by the embedder if applicable.
48 static void set _nativeScript(String path) { 66 static void set _nativeScript(String path) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 V remove(String key) => _map.remove(key.toUpperCase()); 141 V remove(String key) => _map.remove(key.toUpperCase());
124 void clear() => _map.clear(); 142 void clear() => _map.clear();
125 void forEach(void f(String key, V value)) => _map.forEach(f); 143 void forEach(void f(String key, V value)) => _map.forEach(f);
126 Iterable<String> get keys => _map.keys; 144 Iterable<String> get keys => _map.keys;
127 Iterable<V> get values => _map.values; 145 Iterable<V> get values => _map.values;
128 int get length => _map.length; 146 int get length => _map.length;
129 bool get isEmpty => _map.isEmpty; 147 bool get isEmpty => _map.isEmpty;
130 bool get isNotEmpty => _map.isNotEmpty; 148 bool get isNotEmpty => _map.isNotEmpty;
131 String toString() => _map.toString(); 149 String toString() => _map.toString();
132 } 150 }
OLDNEW
« sdk/lib/io/platform.dart ('K') | « sdk/lib/io/platform.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698