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