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) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 JavaFile.relative(JavaFile base, String child) { | 65 JavaFile.relative(JavaFile base, String child) { |
66 this._path = base._path.join(new Path(child)); | 66 this._path = base._path.join(new Path(child)); |
67 } | 67 } |
68 JavaFile.fromUri(Uri uri) : this(uri.path); | 68 JavaFile.fromUri(Uri uri) : this(uri.path); |
69 int get hashCode => _path.hashCode; | 69 int get hashCode => _path.hashCode; |
70 bool operator ==(other) { | 70 bool operator ==(other) { |
71 return other is JavaFile && other._path.toNativePath() == _path.toNativePath
(); | 71 return other is JavaFile && other._path.toNativePath() == _path.toNativePath
(); |
72 } | 72 } |
73 String getPath() => _path.toNativePath(); | 73 String getPath() => _path.toNativePath(); |
74 String getName() => _path.filename; | 74 String getName() => _path.filename; |
75 String getParent() => _path.directoryPath.toNativePath(); | 75 String getParent() { |
76 JavaFile getParentFile() => new JavaFile(getParent()); | 76 var result = _path.directoryPath.toNativePath(); |
| 77 // "." or "/" or "C:\" |
| 78 if (result.length < 4) return null; |
| 79 return result; |
| 80 } |
| 81 JavaFile getParentFile() { |
| 82 var parent = getParent(); |
| 83 if (parent == null) return null; |
| 84 return new JavaFile(parent); |
| 85 } |
77 String getAbsolutePath() => _path.canonicalize().toNativePath(); | 86 String getAbsolutePath() => _path.canonicalize().toNativePath(); |
78 String getCanonicalPath() => _path.canonicalize().toNativePath(); | 87 String getCanonicalPath() => _path.canonicalize().toNativePath(); |
79 JavaFile getAbsoluteFile() => new JavaFile(getAbsolutePath()); | 88 JavaFile getAbsoluteFile() => new JavaFile(getAbsolutePath()); |
80 JavaFile getCanonicalFile() => new JavaFile(getCanonicalPath()); | 89 JavaFile getCanonicalFile() => new JavaFile(getCanonicalPath()); |
81 bool exists() { | 90 bool exists() { |
82 if (_newFile().existsSync()) { | 91 if (_newFile().existsSync()) { |
83 return true; | 92 return true; |
84 } | 93 } |
85 if (_newDirectory().existsSync()) { | 94 if (_newDirectory().existsSync()) { |
86 return true; | 95 return true; |
(...skipping 10 matching lines...) Expand all Loading... |
97 List<JavaFile> files = []; | 106 List<JavaFile> files = []; |
98 List<FileSystemEntity> entities = _newDirectory().listSync(); | 107 List<FileSystemEntity> entities = _newDirectory().listSync(); |
99 for (FileSystemEntity entity in entities) { | 108 for (FileSystemEntity entity in entities) { |
100 files.add(new JavaFile(entity.path)); | 109 files.add(new JavaFile(entity.path)); |
101 } | 110 } |
102 return files; | 111 return files; |
103 } | 112 } |
104 File _newFile() => new File.fromPath(_path); | 113 File _newFile() => new File.fromPath(_path); |
105 Directory _newDirectory() => new Directory.fromPath(_path); | 114 Directory _newDirectory() => new Directory.fromPath(_path); |
106 } | 115 } |
OLD | NEW |