OLD | NEW |
1 library java.io; | 1 library java.io; |
2 | 2 |
3 import "dart:io"; | 3 import "dart:io"; |
4 import "dart:uri"; | 4 import "dart:uri"; |
5 | 5 |
6 class JavaSystemIO { | 6 class JavaSystemIO { |
7 static Map<String, String> _properties = new Map(); | 7 static Map<String, String> _properties = new Map(); |
8 static String getProperty(String name) { | 8 static String getProperty(String name) { |
9 { | 9 { |
10 String value = _properties[name]; | 10 String value = _properties[name]; |
11 if (value != null) { | 11 if (value != null) { |
12 return value; | 12 return value; |
13 } | 13 } |
14 } | 14 } |
15 if (name == 'os.name') { | 15 if (name == 'os.name') { |
16 return Platform.operatingSystem; | 16 return Platform.operatingSystem; |
17 } | 17 } |
18 if (name == 'line.separator') { | 18 if (name == 'line.separator') { |
19 if (Platform.operatingSystem == 'windows') { | 19 if (Platform.operatingSystem == 'windows') { |
20 return '\r\n'; | 20 return '\r\n'; |
21 } | 21 } |
22 return '\n'; | 22 return '\n'; |
23 } | 23 } |
24 if (name == 'com.google.dart.sdk') { | 24 if (name == 'com.google.dart.sdk') { |
25 String exec = new Options().executable; | 25 String exec = new Options().executable; |
26 if (exec.length != 0) { | 26 if (exec.length != 0) { |
27 String sdkPath = new Path(exec).directoryPath.directoryPath.toString(); | 27 String sdkPath; |
| 28 // may be "xcodebuild/ReleaseIA32/dart" with "dart-sdk" sibling |
| 29 { |
| 30 sdkPath = new Path(exec).directoryPath.append("dart-sdk").toNativePath
(); |
| 31 if (new Directory(sdkPath).existsSync()) { |
| 32 _properties[name] = sdkPath; |
| 33 return sdkPath; |
| 34 } |
| 35 } |
| 36 // probably be "dart-sdk/bin/dart" |
| 37 sdkPath = new Path(exec).directoryPath.directoryPath.toString(); |
28 _properties[name] = sdkPath; | 38 _properties[name] = sdkPath; |
29 return sdkPath; | 39 return sdkPath; |
30 } | 40 } |
31 } | 41 } |
32 return null; | 42 return null; |
33 } | 43 } |
34 static String setProperty(String name, String value) { | 44 static String setProperty(String name, String value) { |
35 String oldValue = _properties[name]; | 45 String oldValue = _properties[name]; |
36 _properties[name] = value; | 46 _properties[name] = value; |
37 return oldValue; | 47 return oldValue; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 return true; | 80 return true; |
71 } | 81 } |
72 return false; | 82 return false; |
73 } | 83 } |
74 Uri toURI() => new Uri.fromComponents(path: _path.toString()); | 84 Uri toURI() => new Uri.fromComponents(path: _path.toString()); |
75 String readAsStringSync() => _newFile().readAsStringSync(); | 85 String readAsStringSync() => _newFile().readAsStringSync(); |
76 int lastModified() => _newFile().lastModifiedSync().millisecondsSinceEpoch; | 86 int lastModified() => _newFile().lastModifiedSync().millisecondsSinceEpoch; |
77 File _newFile() => new File.fromPath(_path); | 87 File _newFile() => new File.fromPath(_path); |
78 Directory _newDirectory() => new Directory.fromPath(_path); | 88 Directory _newDirectory() => new Directory.fromPath(_path); |
79 } | 89 } |
OLD | NEW |