Index: pkg/path/lib/path.dart |
diff --git a/pkg/path/lib/path.dart b/pkg/path/lib/path.dart |
index da4c935f0bafb532b2c3cc0285d2303c18ba9429..7b133bbebf306ab23b458f449450e821eb7be46d 100644 |
--- a/pkg/path/lib/path.dart |
+++ b/pkg/path/lib/path.dart |
@@ -46,11 +46,6 @@ |
/// even when the program is run on a POSIX machine. |
library path; |
-@MirrorsUsed(targets: 'dart.dom.html.window, ' |
- 'dart.io.Directory.current, ' |
- 'dart.io.Platform.operatingSystem') |
-import 'dart:mirrors'; |
- |
/// An internal builder for the current OS so we can provide a straight |
/// functional interface and not require users to create one. |
final _builder = new Builder(); |
@@ -69,19 +64,6 @@ final url = new Builder(style: Style.url); |
void _growListFront(List list, int length, fillValue) => |
list.insertAll(0, new List.filled(length, fillValue)); |
-/// If we're running in the server-side Dart VM, this will return a |
-/// [LibraryMirror] that gives access to the `dart:io` library. |
-/// |
-/// If `dart:io` is not available, this returns null. |
-LibraryMirror get _io => currentMirrorSystem().libraries[Uri.parse('dart:io')]; |
- |
-// TODO(nweiz): when issue 6490 or 6943 are fixed, make this work under dart2js. |
-/// If we're running in Dartium, this will return a [LibraryMirror] that gives |
-/// access to the `dart:html` library. |
-/// |
-/// If `dart:html` is not available, this returns null. |
-LibraryMirror get _html => |
- currentMirrorSystem().libraries[Uri.parse('dart:html')]; |
/// Gets the path to the current working directory. |
/// |
@@ -89,13 +71,13 @@ LibraryMirror get _html => |
/// currently returns `.` due to technical constraints. In the future, it will |
/// return the current URL. |
String get current { |
- if (_io != null) { |
- return (_io.declarations[#Directory] as ClassMirror) |
- .getField(#current).reflectee.path; |
- } else if (_html != null) { |
- return _html.getField(#window).reflectee.location.href; |
+ var uri = Uri.base; |
+ if (Style.platform == Style.url) { |
+ return uri.toString(); |
} else { |
- return '.'; |
+ var path = uri.toFilePath(); |
+ // Remove trailing '/' or '\'. |
+ return path.substring(0, path.length - 1); |
} |
} |
@@ -866,13 +848,8 @@ abstract class Style { |
/// Gets the type of the host platform. |
static Style _getPlatformStyle() { |
- if (_io == null) return Style.url; |
- |
- if ((_io.declarations[#Platform] as ClassMirror).getField(#operatingSystem) |
- .reflectee == 'windows') { |
- return Style.windows; |
- } |
- |
+ if (Uri.base.scheme != 'file') return Style.url; |
Bob Nystrom
2013/11/06 18:00:36
This does the wrong thing if you open a file in Da
Anders Johnsen
2013/11/06 18:07:10
Ahh, interesting point. I'll see if I can come up
|
+ if (new Uri.file('a/b').toFilePath() == 'a\\b') return Style.windows; |
return Style.posix; |
} |