Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Unified Diff: editor/util/plugins/com.google.dart.java2dart/resources/java_io.dart

Issue 12543009: Use JavaFile instead of Dart File. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: editor/util/plugins/com.google.dart.java2dart/resources/java_io.dart
diff --git a/editor/util/plugins/com.google.dart.java2dart/resources/java_io.dart b/editor/util/plugins/com.google.dart.java2dart/resources/java_io.dart
index ab1d025bd8db3c786e0e093568dfd0ef2cce1f52..0167f595331154536652420d4a60074ac62bc3ce 100644
--- a/editor/util/plugins/com.google.dart.java2dart/resources/java_io.dart
+++ b/editor/util/plugins/com.google.dart.java2dart/resources/java_io.dart
@@ -4,8 +4,6 @@ import "dart:io";
import "dart:uri";
class JavaSystemIO {
- static final String pathSeparator = Platform.pathSeparator;
- static final int pathSeparatorChar = Platform.pathSeparator.codeUnitAt(0);
static String getProperty(String name) {
if (name == 'os.name') {
return Platform.operatingSystem;
@@ -21,21 +19,30 @@ class JavaSystemIO {
static String getenv(String name) => Platform.environment[name];
}
-
-File newRelativeFile(File base, String child) {
- var childPath = new Path(base.fullPathSync()).join(new Path(child));
- return new File.fromPath(childPath);
-}
-
-File newFileFromUri(Uri uri) {
- return new File(uri.path);
-}
-
-File getAbsoluteFile(File file) {
- var path = file.fullPathSync();
- return new File(path);
-}
-
-Uri newUriFromFile(File file) {
- return new Uri.fromComponents(path: file.fullPathSync());
+class JavaFile {
+ static final String separator = Platform.pathSeparator;
+ static final int separatorChar = Platform.pathSeparator.codeUnitAt(0);
+ Path _path;
+ JavaFile(String path) {
+ this._path = new Path(path);
+ }
+ JavaFile.relative(JavaFile base, String child) {
+ this._path = base._path.join(new Path(child));
+ }
+ JavaFile.fromUri(Uri uri) : this(uri.path);
+ int get hashCode => _path.hashCode;
+ bool operator ==(other) {
+ return other is JavaFile && _path == other._path;
+ }
+ String getPath() => _path.toNativePath();
+ String getName() => _path.filename;
+ String getParent() => _path.directoryPath.toNativePath();
+ JavaFile getParentFile() => new JavaFile(getParent());
+ String getAbsolutePath() => _path.canonicalize().toNativePath();
+ String getCanonicalPath() => _path.canonicalize().toNativePath();
+ JavaFile getAbsoluteFile() => new JavaFile(getAbsolutePath());
+ JavaFile getCanonicalFile() => new JavaFile(getCanonicalPath());
+ bool exists() => new File.fromPath(_path).existsSync();
+ Uri toURI() => new Uri.fromComponents(path: _path.toString());
+ String readAsStringSync() => new File.fromPath(_path).readAsStringSync();
}

Powered by Google App Engine
This is Rietveld 408576698