OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// A comprehensive, cross-platform path manipulation library. | 5 /// A comprehensive, cross-platform path manipulation library. |
6 /// | 6 /// |
7 /// ## Installing ## | 7 /// ## Installing ## |
8 /// | 8 /// |
9 /// Use [pub][] to install this package. Add the following to your | 9 /// Use [pub][] to install this package. Add the following to your |
10 /// `pubspec.yaml` file. | 10 /// `pubspec.yaml` file. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 LibraryMirror get _html => | 83 LibraryMirror get _html => |
84 currentMirrorSystem().libraries[Uri.parse('dart:html')]; | 84 currentMirrorSystem().libraries[Uri.parse('dart:html')]; |
85 | 85 |
86 /// Gets the path to the current working directory. | 86 /// Gets the path to the current working directory. |
87 /// | 87 /// |
88 /// In the browser, this means the current URL. When using dart2js, this | 88 /// In the browser, this means the current URL. When using dart2js, this |
89 /// currently returns `.` due to technical constraints. In the future, it will | 89 /// currently returns `.` due to technical constraints. In the future, it will |
90 /// return the current URL. | 90 /// return the current URL. |
91 String get current { | 91 String get current { |
92 if (_io != null) { | 92 if (_io != null) { |
93 return _io.classes[#Directory].getField(#current).reflectee.path; | 93 return (_io.declarations[#Directory] as ClassMirror) |
| 94 .getField(#current).reflectee.path; |
94 } else if (_html != null) { | 95 } else if (_html != null) { |
95 return _html.getField(#window).reflectee.location.href; | 96 return _html.getField(#window).reflectee.location.href; |
96 } else { | 97 } else { |
97 return '.'; | 98 return '.'; |
98 } | 99 } |
99 } | 100 } |
100 | 101 |
101 /// Gets the path separator for the current platform. This is `\` on Windows | 102 /// Gets the path separator for the current platform. This is `\` on Windows |
102 /// and `/` on other platforms (including the browser). | 103 /// and `/` on other platforms (including the browser). |
103 String get separator => _builder.separator; | 104 String get separator => _builder.separator; |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 /// The style of the host platform. | 861 /// The style of the host platform. |
861 /// | 862 /// |
862 /// When running on the command line, this will be [windows] or [posix] based | 863 /// When running on the command line, this will be [windows] or [posix] based |
863 /// on the host operating system. On a browser, this will be [url]. | 864 /// on the host operating system. On a browser, this will be [url]. |
864 static final platform = _getPlatformStyle(); | 865 static final platform = _getPlatformStyle(); |
865 | 866 |
866 /// Gets the type of the host platform. | 867 /// Gets the type of the host platform. |
867 static Style _getPlatformStyle() { | 868 static Style _getPlatformStyle() { |
868 if (_io == null) return Style.url; | 869 if (_io == null) return Style.url; |
869 | 870 |
870 if (_io.classes[#Platform].getField(#operatingSystem) | 871 if ((_io.declarations[#Platform] as ClassMirror).getField(#operatingSystem) |
871 .reflectee == 'windows') { | 872 .reflectee == 'windows') { |
872 return Style.windows; | 873 return Style.windows; |
873 } | 874 } |
874 | 875 |
875 return Style.posix; | 876 return Style.posix; |
876 } | 877 } |
877 | 878 |
878 /// The name of this path style. Will be "posix" or "windows". | 879 /// The name of this path style. Will be "posix" or "windows". |
879 String get name; | 880 String get name; |
880 | 881 |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 // doesn't count. | 1197 // doesn't count. |
1197 if (lastDot <= 0) return [file, '']; | 1198 if (lastDot <= 0) return [file, '']; |
1198 | 1199 |
1199 return [file.substring(0, lastDot), file.substring(lastDot)]; | 1200 return [file.substring(0, lastDot), file.substring(lastDot)]; |
1200 } | 1201 } |
1201 | 1202 |
1202 _ParsedPath clone() => new _ParsedPath( | 1203 _ParsedPath clone() => new _ParsedPath( |
1203 style, root, isRootRelative, | 1204 style, root, isRootRelative, |
1204 new List.from(parts), new List.from(separators)); | 1205 new List.from(parts), new List.from(separators)); |
1205 } | 1206 } |
OLD | NEW |