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

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

Issue 11578048: Make Platform.environment case-insensitive on Windows. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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 | « sdk/lib/io/platform.dart ('k') | tests/standalone/io/windows_environment_script.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/platform_impl.dart
diff --git a/sdk/lib/io/platform_impl.dart b/sdk/lib/io/platform_impl.dart
index 63ac5a82491b43e1154d267a0d642983bade4872..cbc8443dce3773fe450e9734e8b479e30f366d81 100644
--- a/sdk/lib/io/platform_impl.dart
+++ b/sdk/lib/io/platform_impl.dart
@@ -37,7 +37,8 @@ class _Platform {
if (env is OSError) {
throw env;
} else {
- var result = new Map();
+ var isWindows = operatingSystem == 'windows';
+ var result = isWindows ? new _CaseInsensitiveStringMap() : new Map();
for (var str in env) {
// When running on Windows through cmd.exe there are strange
// environment variables that are used to record the current
@@ -57,3 +58,35 @@ class _Platform {
}
}
}
+
+// Environment variables are case-insensitive on Windows. In order
+// to reflect that we use a case-insensitive string map on Windows.
+class _CaseInsensitiveStringMap<V> implements Map<String, V> {
+ _CaseInsensitiveStringMap() : _map = new Map<String, V>();
+
+ _CaseInsensitiveStringMap.from(Map<String, V> other)
+ : _map = new Map<String, V>() {
+ other.forEach((String key, V value) {
+ _map[key.toUpperCase()] = value;
+ });
+ }
+
+ bool containsKey(String key) => _map.containsKey(key.toUpperCase());
+ bool containsValue(V value) => _map.containsValue(value);
+ V operator [](String key) => _map[key.toUpperCase()];
+ void operator []=(String key, V value) {
+ _map[key.toUpperCase()] = value;
+ }
+ V putIfAbsent(String key, V ifAbsent()) {
+ _map.putIfAbsent(key.toUpperCase(), ifAbsent);
+ }
+ V remove(String key) => _map.remove(key.toUpperCase());
+ void clear() => _map.clear();
+ void forEach(void f(String key, V value)) => _map.forEach(f);
+ Collection<String> get keys => _map.keys;
+ Collection<V> get values => _map.values;
+ int get length => _map.length;
+ bool get isEmpty => _map.isEmpty;
+
+ Map<String, V> _map;
+}
« no previous file with comments | « sdk/lib/io/platform.dart ('k') | tests/standalone/io/windows_environment_script.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698