| OLD | NEW |
| (Empty) |
| 1 library java.io; | |
| 2 | |
| 3 import "dart:io"; | |
| 4 import "dart:uri"; | |
| 5 | |
| 6 class JavaSystemIO { | |
| 7 static Map<String, String> _properties = new Map(); | |
| 8 static String getProperty(String name) { | |
| 9 { | |
| 10 String value = _properties[name]; | |
| 11 if (value != null) { | |
| 12 return value; | |
| 13 } | |
| 14 } | |
| 15 if (name == 'os.name') { | |
| 16 return Platform.operatingSystem; | |
| 17 } | |
| 18 if (name == 'line.separator') { | |
| 19 if (Platform.operatingSystem == 'windows') { | |
| 20 return '\r\n'; | |
| 21 } | |
| 22 return '\n'; | |
| 23 } | |
| 24 if (name == 'com.google.dart.sdk') { | |
| 25 String exec = new Options().executable; | |
| 26 if (exec.length != 0) { | |
| 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(); | |
| 38 _properties[name] = sdkPath; | |
| 39 return sdkPath; | |
| 40 } | |
| 41 } | |
| 42 return null; | |
| 43 } | |
| 44 static String setProperty(String name, String value) { | |
| 45 String oldValue = _properties[name]; | |
| 46 _properties[name] = value; | |
| 47 return oldValue; | |
| 48 } | |
| 49 static String getenv(String name) => Platform.environment[name]; | |
| 50 } | |
| 51 | |
| 52 class JavaFile { | |
| 53 static final String separator = Platform.pathSeparator; | |
| 54 static final int separatorChar = Platform.pathSeparator.codeUnitAt(0); | |
| 55 Path _path; | |
| 56 JavaFile(String path) { | |
| 57 this._path = new Path(path); | |
| 58 } | |
| 59 JavaFile.relative(JavaFile base, String child) { | |
| 60 this._path = base._path.join(new Path(child)); | |
| 61 } | |
| 62 JavaFile.fromUri(Uri uri) : this(uri.path); | |
| 63 int get hashCode => _path.hashCode; | |
| 64 bool operator ==(other) { | |
| 65 return other is JavaFile && other._path.toNativePath() == _path.toNativePath
(); | |
| 66 } | |
| 67 String getPath() => _path.toNativePath(); | |
| 68 String getName() => _path.filename; | |
| 69 String getParent() => _path.directoryPath.toNativePath(); | |
| 70 JavaFile getParentFile() => new JavaFile(getParent()); | |
| 71 String getAbsolutePath() => _path.canonicalize().toNativePath(); | |
| 72 String getCanonicalPath() => _path.canonicalize().toNativePath(); | |
| 73 JavaFile getAbsoluteFile() => new JavaFile(getAbsolutePath()); | |
| 74 JavaFile getCanonicalFile() => new JavaFile(getCanonicalPath()); | |
| 75 bool exists() { | |
| 76 if (_newFile().existsSync()) { | |
| 77 return true; | |
| 78 } | |
| 79 if (_newDirectory().existsSync()) { | |
| 80 return true; | |
| 81 } | |
| 82 return false; | |
| 83 } | |
| 84 Uri toURI() => new Uri.fromComponents(path: _path.toString()); | |
| 85 String readAsStringSync() => _newFile().readAsStringSync(); | |
| 86 int lastModified() => _newFile().lastModifiedSync().millisecondsSinceEpoch; | |
| 87 File _newFile() => new File.fromPath(_path); | |
| 88 Directory _newDirectory() => new Directory.fromPath(_path); | |
| 89 } | |
| OLD | NEW |