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 final String pathSeparator = Platform.pathSeparator; | |
8 static final int pathSeparatorChar = Platform.pathSeparator.codeUnitAt(0); | |
9 static String getProperty(String name) { | 7 static String getProperty(String name) { |
10 if (name == 'os.name') { | 8 if (name == 'os.name') { |
11 return Platform.operatingSystem; | 9 return Platform.operatingSystem; |
12 } | 10 } |
13 if (name == 'line.separator') { | 11 if (name == 'line.separator') { |
14 if (Platform.operatingSystem == 'windows') { | 12 if (Platform.operatingSystem == 'windows') { |
15 return '\r\n'; | 13 return '\r\n'; |
16 } | 14 } |
17 return '\n'; | 15 return '\n'; |
18 } | 16 } |
19 return null; | 17 return null; |
20 } | 18 } |
21 static String getenv(String name) => Platform.environment[name]; | 19 static String getenv(String name) => Platform.environment[name]; |
22 } | 20 } |
23 | 21 |
24 | 22 class JavaFile { |
25 File newRelativeFile(File base, String child) { | 23 static final String separator = Platform.pathSeparator; |
26 var childPath = new Path(base.fullPathSync()).join(new Path(child)); | 24 static final int separatorChar = Platform.pathSeparator.codeUnitAt(0); |
27 return new File.fromPath(childPath); | 25 Path _path; |
| 26 JavaFile(String path) { |
| 27 this._path = new Path(path); |
| 28 } |
| 29 JavaFile.relative(JavaFile base, String child) { |
| 30 this._path = base._path.join(new Path(child)); |
| 31 } |
| 32 JavaFile.fromUri(Uri uri) : this(uri.path); |
| 33 int get hashCode => _path.hashCode; |
| 34 bool operator ==(other) { |
| 35 return other is JavaFile && _path == other._path; |
| 36 } |
| 37 String getPath() => _path.toNativePath(); |
| 38 String getName() => _path.filename; |
| 39 String getParent() => _path.directoryPath.toNativePath(); |
| 40 JavaFile getParentFile() => new JavaFile(getParent()); |
| 41 String getAbsolutePath() => _path.canonicalize().toNativePath(); |
| 42 String getCanonicalPath() => _path.canonicalize().toNativePath(); |
| 43 JavaFile getAbsoluteFile() => new JavaFile(getAbsolutePath()); |
| 44 JavaFile getCanonicalFile() => new JavaFile(getCanonicalPath()); |
| 45 bool exists() => new File.fromPath(_path).existsSync(); |
| 46 Uri toURI() => new Uri.fromComponents(path: _path.toString()); |
| 47 String readAsStringSync() => new File.fromPath(_path).readAsStringSync(); |
28 } | 48 } |
29 | |
30 File newFileFromUri(Uri uri) { | |
31 return new File(uri.path); | |
32 } | |
33 | |
34 File getAbsoluteFile(File file) { | |
35 var path = file.fullPathSync(); | |
36 return new File(path); | |
37 } | |
38 | |
39 Uri newUriFromFile(File file) { | |
40 return new Uri.fromComponents(path: file.fullPathSync()); | |
41 } | |
OLD | NEW |