Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.internal_style; | 5 library path.internal_style; |
| 6 | 6 |
| 7 import 'context.dart'; | 7 import 'context.dart'; |
| 8 import 'style.dart'; | 8 import 'style.dart'; |
| 9 | 9 |
| 10 /// The internal interface for the [Style] type. | 10 /// The internal interface for the [Style] type. |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 /// Returns whether this path component needs a separator after it. | 27 /// Returns whether this path component needs a separator after it. |
| 28 /// | 28 /// |
| 29 /// Windows and POSIX styles just need separators when the previous component | 29 /// Windows and POSIX styles just need separators when the previous component |
| 30 /// doesn't already end in a separator, but the URL always needs to place a | 30 /// doesn't already end in a separator, but the URL always needs to place a |
| 31 /// separator between the root and the first component, even if the root | 31 /// separator between the root and the first component, even if the root |
| 32 /// already ends in a separator character. For example, to join "file://" and | 32 /// already ends in a separator character. For example, to join "file://" and |
| 33 /// "usr", an additional "/" is needed (making "file:///usr"). | 33 /// "usr", an additional "/" is needed (making "file:///usr"). |
| 34 bool needsSeparator(String path); | 34 bool needsSeparator(String path); |
| 35 | 35 |
| 36 /// Returns the number of characters of the root part. Returns 0 if the path | |
|
nweiz
2014/08/05 20:22:26
Nit: Looks like this is still a two-sentence first
Anders Johnsen
2014/08/06 07:05:15
My understanding was the it was the first paragrap
| |
| 37 /// is relative. | |
| 38 /// | |
| 39 /// If the path is root-relative, the root length is 1. | |
| 40 int rootLength(String path); | |
| 41 | |
| 36 /// Gets the root prefix of [path] if path is absolute. If [path] is relative, | 42 /// Gets the root prefix of [path] if path is absolute. If [path] is relative, |
| 37 /// returns `null`. | 43 /// returns `null`. |
| 38 String getRoot(String path); | 44 String getRoot(String path) { |
| 45 var length = rootLength(path); | |
| 46 if (length > 0) return path.substring(0, length); | |
| 47 return isRootRelative(path) ? path[0] : null; | |
| 48 } | |
| 39 | 49 |
| 40 /// Gets the root prefix of [path] if it's root-relative. | 50 /// Gets if [path] is root-relative. |
|
nweiz
2014/08/05 20:22:26
"Gets if" -> "Returns whether"
Anders Johnsen
2014/08/06 07:05:15
Done.
| |
| 41 /// | 51 /// |
| 42 /// If [path] is relative or absolute and not root-relative, returns `null`. | 52 /// If [path] is relative or absolute and not root-relative, returns `false`. |
| 43 String getRelativeRoot(String path); | 53 bool isRootRelative(String path); |
| 44 | 54 |
| 45 /// Returns the path represented by [uri] in this style. | 55 /// Returns the path represented by [uri] in this style. |
| 46 String pathFromUri(Uri uri); | 56 String pathFromUri(Uri uri); |
| 47 | 57 |
| 48 /// Returns the URI that represents the relative path made of [parts]. | 58 /// Returns the URI that represents the relative path made of [parts]. |
| 49 Uri relativePathToUri(String path) => | 59 Uri relativePathToUri(String path) => |
| 50 new Uri(pathSegments: context.split(path)); | 60 new Uri(pathSegments: context.split(path)); |
| 51 | 61 |
| 52 /// Returns the URI that represents [path], which is assumed to be absolute. | 62 /// Returns the URI that represents [path], which is assumed to be absolute. |
| 53 Uri absolutePathToUri(String path); | 63 Uri absolutePathToUri(String path); |
| 54 } | 64 } |
| OLD | NEW |