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[const Symbol('Directory')] | 93 return _io.classes[#Directory].getField(#current).reflectee.path; |
94 .getField(const Symbol('current')).reflectee.path; | |
95 } else if (_html != null) { | 94 } else if (_html != null) { |
96 return _html.getField(const Symbol('window')) | 95 return _html.getField(#window).reflectee.location.href; |
97 .reflectee.location.href; | |
98 } else { | 96 } else { |
99 return '.'; | 97 return '.'; |
100 } | 98 } |
101 } | 99 } |
102 | 100 |
103 /// Gets the path separator for the current platform. This is `\` on Windows | 101 /// Gets the path separator for the current platform. This is `\` on Windows |
104 /// and `/` on other platforms (including the browser). | 102 /// and `/` on other platforms (including the browser). |
105 String get separator => _builder.separator; | 103 String get separator => _builder.separator; |
106 | 104 |
107 /// Converts [path] to an absolute path by resolving it relative to the current | 105 /// Converts [path] to an absolute path by resolving it relative to the current |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 /// The style of the host platform. | 860 /// The style of the host platform. |
863 /// | 861 /// |
864 /// When running on the command line, this will be [windows] or [posix] based | 862 /// When running on the command line, this will be [windows] or [posix] based |
865 /// on the host operating system. On a browser, this will be [url]. | 863 /// on the host operating system. On a browser, this will be [url]. |
866 static final platform = _getPlatformStyle(); | 864 static final platform = _getPlatformStyle(); |
867 | 865 |
868 /// Gets the type of the host platform. | 866 /// Gets the type of the host platform. |
869 static Style _getPlatformStyle() { | 867 static Style _getPlatformStyle() { |
870 if (_io == null) return Style.url; | 868 if (_io == null) return Style.url; |
871 | 869 |
872 if (_io.classes[const Symbol('Platform')] | 870 if (_io.classes[#Platform].getField(#operatingSystem) |
873 .getField(const Symbol('operatingSystem')).reflectee == 'windows') { | 871 .reflectee == 'windows') { |
874 return Style.windows; | 872 return Style.windows; |
875 } | 873 } |
876 | 874 |
877 return Style.posix; | 875 return Style.posix; |
878 } | 876 } |
879 | 877 |
880 /// The name of this path style. Will be "posix" or "windows". | 878 /// The name of this path style. Will be "posix" or "windows". |
881 String get name; | 879 String get name; |
882 | 880 |
883 /// The path separator for this style. On POSIX, this is `/`. On Windows, | 881 /// The path separator for this style. On POSIX, this is `/`. On Windows, |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1198 // doesn't count. | 1196 // doesn't count. |
1199 if (lastDot <= 0) return [file, '']; | 1197 if (lastDot <= 0) return [file, '']; |
1200 | 1198 |
1201 return [file.substring(0, lastDot), file.substring(lastDot)]; | 1199 return [file.substring(0, lastDot), file.substring(lastDot)]; |
1202 } | 1200 } |
1203 | 1201 |
1204 _ParsedPath clone() => new _ParsedPath( | 1202 _ParsedPath clone() => new _ParsedPath( |
1205 style, root, isRootRelative, | 1203 style, root, isRootRelative, |
1206 new List.from(parts), new List.from(separators)); | 1204 new List.from(parts), new List.from(separators)); |
1207 } | 1205 } |
OLD | NEW |