OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library path.parsed_path; | 5 library path.parsed_path; |
6 | 6 |
| 7 import 'internal_style.dart'; |
7 import 'style.dart'; | 8 import 'style.dart'; |
8 | 9 |
9 // TODO(rnystrom): Make this public? | |
10 class ParsedPath { | 10 class ParsedPath { |
11 /// The [Style] that was used to parse this path. | 11 /// The [InternalStyle] that was used to parse this path. |
12 Style style; | 12 InternalStyle style; |
13 | 13 |
14 /// The absolute root portion of the path, or `null` if the path is relative. | 14 /// The absolute root portion of the path, or `null` if the path is relative. |
15 /// On POSIX systems, this will be `null` or "/". On Windows, it can be | 15 /// On POSIX systems, this will be `null` or "/". On Windows, it can be |
16 /// `null`, "//" for a UNC path, or something like "C:\" for paths with drive | 16 /// `null`, "//" for a UNC path, or something like "C:\" for paths with drive |
17 /// letters. | 17 /// letters. |
18 String root; | 18 String root; |
19 | 19 |
20 /// Whether this path is root-relative. | 20 /// Whether this path is root-relative. |
21 /// | 21 /// |
22 /// See [Context.isRootRelative]. | 22 /// See [Context.isRootRelative]. |
(...skipping 10 matching lines...) Expand all Loading... |
33 /// path ends with a trailing separator. | 33 /// path ends with a trailing separator. |
34 List<String> separators; | 34 List<String> separators; |
35 | 35 |
36 /// The file extension of the last non-empty part, or "" if it doesn't have | 36 /// The file extension of the last non-empty part, or "" if it doesn't have |
37 /// one. | 37 /// one. |
38 String get extension => _splitExtension()[1]; | 38 String get extension => _splitExtension()[1]; |
39 | 39 |
40 /// `true` if this is an absolute path. | 40 /// `true` if this is an absolute path. |
41 bool get isAbsolute => root != null; | 41 bool get isAbsolute => root != null; |
42 | 42 |
43 factory ParsedPath.parse(String path, Style style) { | 43 factory ParsedPath.parse(String path, InternalStyle style) { |
44 var before = path; | 44 var before = path; |
45 | 45 |
46 // Remove the root prefix, if any. | 46 // Remove the root prefix, if any. |
47 var root = style.getRoot(path); | 47 var root = style.getRoot(path); |
48 var isRootRelative = style.getRelativeRoot(path) != null; | 48 var isRootRelative = style.getRelativeRoot(path) != null; |
49 if (root != null) path = path.substring(root.length); | 49 if (root != null) path = path.substring(root.length); |
50 | 50 |
51 // Split the parts on path separators. | 51 // Split the parts on path separators. |
52 var parts = []; | 52 var parts = []; |
53 var separators = []; | 53 var separators = []; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 if (lastDot <= 0) return [file, '']; | 177 if (lastDot <= 0) return [file, '']; |
178 | 178 |
179 return [file.substring(0, lastDot), file.substring(lastDot)]; | 179 return [file.substring(0, lastDot), file.substring(lastDot)]; |
180 } | 180 } |
181 | 181 |
182 ParsedPath clone() => new ParsedPath._( | 182 ParsedPath clone() => new ParsedPath._( |
183 style, root, isRootRelative, | 183 style, root, isRootRelative, |
184 new List.from(parts), new List.from(separators)); | 184 new List.from(parts), new List.from(separators)); |
185 } | 185 } |
186 | 186 |
OLD | NEW |