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

Unified Diff: pkg/front_end/lib/physical_file_system.dart

Issue 2614063007: Use URIs rather than paths in front end API. (Closed)
Patch Set: Run dartfmt Created 3 years, 11 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: pkg/front_end/lib/physical_file_system.dart
diff --git a/pkg/front_end/lib/physical_file_system.dart b/pkg/front_end/lib/physical_file_system.dart
index 0ed5d8b0926dd27bd26ea2f97eb6e336d82325bf..757eb60e834f4056ee67d0d07c6d931147be8996 100644
--- a/pkg/front_end/lib/physical_file_system.dart
+++ b/pkg/front_end/lib/physical_file_system.dart
@@ -24,36 +24,38 @@ class PhysicalFileSystem implements FileSystem {
p.Context get context => p.context;
@override
- FileSystemEntity entityForPath(String path) =>
- new _PhysicalFileSystemEntity(context.normalize(context.absolute(path)));
-
- @override
FileSystemEntity entityForUri(Uri uri) {
- if (uri.scheme != 'file') throw new ArgumentError('File URI expected');
+ if (uri.scheme != 'file' && uri.scheme != '') {
+ throw new ArgumentError('File URI expected');
+ }
// Note: we don't have to verify that the URI's path is absolute, because
// URIs with non-empty schemes always have absolute paths.
- return entityForPath(context.fromUri(uri));
+ var path = context.fromUri(uri);
+ return new _PhysicalFileSystemEntity(
+ context.normalize(context.absolute(path)));
}
}
/// Concrete implementation of [FileSystemEntity] for use by
/// [PhysicalFileSystem].
class _PhysicalFileSystemEntity implements FileSystemEntity {
- @override
- final String path;
+ final String _path;
- _PhysicalFileSystemEntity(this.path);
+ _PhysicalFileSystemEntity(this._path);
+
+ @override
+ int get hashCode => _path.hashCode;
@override
- int get hashCode => path.hashCode;
+ Uri get uri => p.toUri(_path);
@override
bool operator ==(Object other) =>
- other is _PhysicalFileSystemEntity && other.path == path;
+ other is _PhysicalFileSystemEntity && other._path == _path;
@override
- Future<List<int>> readAsBytes() => new io.File(path).readAsBytes();
+ Future<List<int>> readAsBytes() => new io.File(_path).readAsBytes();
Siggi Cherem (dart-lang) 2017/01/11 22:59:53 would `new io.File.fromUri` work as well (and no n
Paul Berry 2017/01/12 23:10:04 Yes, that simplifies things. Thanks.
@override
- Future<String> readAsString() => new io.File(path).readAsString();
+ Future<String> readAsString() => new io.File(_path).readAsString();
}

Powered by Google App Engine
This is Rietveld 408576698