OLD | NEW |
1 library java.io; | 1 library java.io; |
2 | 2 |
3 import "dart:io"; | 3 import "dart:io"; |
4 | 4 |
5 class JavaSystemIO { | 5 class JavaSystemIO { |
6 static Map<String, String> _properties = new Map(); | 6 static Map<String, String> _properties = new Map(); |
7 static String getProperty(String name) { | 7 static String getProperty(String name) { |
8 { | 8 { |
9 String value = _properties[name]; | 9 String value = _properties[name]; |
10 if (value != null) { | 10 if (value != null) { |
11 return value; | 11 return value; |
12 } | 12 } |
13 } | 13 } |
14 if (name == 'os.name') { | 14 if (name == 'os.name') { |
15 return Platform.operatingSystem; | 15 return Platform.operatingSystem; |
16 } | 16 } |
17 if (name == 'line.separator') { | 17 if (name == 'line.separator') { |
18 if (Platform.operatingSystem == 'windows') { | 18 if (Platform.operatingSystem == 'windows') { |
19 return '\r\n'; | 19 return '\r\n'; |
20 } | 20 } |
21 return '\n'; | 21 return '\n'; |
22 } | 22 } |
23 if (name == 'com.google.dart.sdk') { | 23 if (name == 'com.google.dart.sdk') { |
| 24 String value = Platform.environment['DART_SDK']; |
| 25 if (value != null) { |
| 26 _properties[name] = value; |
| 27 return value; |
| 28 } |
| 29 } |
| 30 if (name == 'com.google.dart.sdk') { |
24 String exec = new Options().executable; | 31 String exec = new Options().executable; |
25 if (exec.length != 0) { | 32 if (exec.length != 0) { |
26 String sdkPath; | 33 String sdkPath; |
27 // may be "xcodebuild/ReleaseIA32/dart" with "dart-sdk" sibling | 34 // may be "xcodebuild/ReleaseIA32/dart" with "dart-sdk" sibling |
28 { | 35 { |
29 sdkPath = new Path(exec).directoryPath.append("dart-sdk").toNativePath
(); | 36 sdkPath = new Path(exec).directoryPath.append("dart-sdk").toNativePath
(); |
30 if (new Directory(sdkPath).existsSync()) { | 37 if (new Directory(sdkPath).existsSync()) { |
31 _properties[name] = sdkPath; | 38 _properties[name] = sdkPath; |
32 return sdkPath; | 39 return sdkPath; |
33 } | 40 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 return true; | 86 return true; |
80 } | 87 } |
81 return false; | 88 return false; |
82 } | 89 } |
83 bool isDirectory() { | 90 bool isDirectory() { |
84 return _newDirectory().existsSync(); | 91 return _newDirectory().existsSync(); |
85 } | 92 } |
86 Uri toURI() => new Uri(path: _path.toString()); | 93 Uri toURI() => new Uri(path: _path.toString()); |
87 String readAsStringSync() => _newFile().readAsStringSync(); | 94 String readAsStringSync() => _newFile().readAsStringSync(); |
88 int lastModified() => _newFile().lastModifiedSync().millisecondsSinceEpoch; | 95 int lastModified() => _newFile().lastModifiedSync().millisecondsSinceEpoch; |
| 96 List<JavaFile> listFiles() { |
| 97 List<JavaFile> files = []; |
| 98 List<FileSystemEntity> entities = _newDirectory().listSync(); |
| 99 for (FileSystemEntity entity in entities) { |
| 100 files.add(new JavaFile(entity.path)); |
| 101 } |
| 102 return files; |
| 103 } |
89 File _newFile() => new File.fromPath(_path); | 104 File _newFile() => new File.fromPath(_path); |
90 Directory _newDirectory() => new Directory.fromPath(_path); | 105 Directory _newDirectory() => new Directory.fromPath(_path); |
91 } | 106 } |
OLD | NEW |