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 'internal_style.dart'; |
8 import 'style.dart'; | 8 import 'style.dart'; |
9 | 9 |
10 class ParsedPath { | 10 class ParsedPath { |
(...skipping 27 matching lines...) Expand all Loading... |
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, InternalStyle 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.isRootRelative(path); |
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 = []; |
54 | 54 |
55 var start = 0; | 55 var start = 0; |
56 | 56 |
57 if (path.isNotEmpty && style.isSeparator(path.codeUnitAt(0))) { | 57 if (path.isNotEmpty && style.isSeparator(path.codeUnitAt(0))) { |
58 separators.add(path[0]); | 58 separators.add(path[0]); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 if (lastDot <= 0) return [file, '']; | 178 if (lastDot <= 0) return [file, '']; |
179 | 179 |
180 return [file.substring(0, lastDot), file.substring(lastDot)]; | 180 return [file.substring(0, lastDot), file.substring(lastDot)]; |
181 } | 181 } |
182 | 182 |
183 ParsedPath clone() => new ParsedPath._( | 183 ParsedPath clone() => new ParsedPath._( |
184 style, root, isRootRelative, | 184 style, root, isRootRelative, |
185 new List.from(parts), new List.from(separators)); | 185 new List.from(parts), new List.from(separators)); |
186 } | 186 } |
187 | 187 |
OLD | NEW |