Chromium Code Reviews| Index: pkg/path/lib/src/internal_style.dart |
| diff --git a/pkg/path/lib/src/internal_style.dart b/pkg/path/lib/src/internal_style.dart |
| index 67b5d343eb748a40f868c4536df7d27b3262b6df..f78e541a18fc7905f4aade840c5b0171c10bee41 100644 |
| --- a/pkg/path/lib/src/internal_style.dart |
| +++ b/pkg/path/lib/src/internal_style.dart |
| @@ -33,14 +33,24 @@ abstract class InternalStyle extends Style { |
| /// "usr", an additional "/" is needed (making "file:///usr"). |
| bool needsSeparator(String path); |
| + /// 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
|
| + /// is relative. |
| + /// |
| + /// If the path is root-relative, the root length is 1. |
| + int rootLength(String path); |
| + |
| /// Gets the root prefix of [path] if path is absolute. If [path] is relative, |
| /// returns `null`. |
| - String getRoot(String path); |
| + String getRoot(String path) { |
| + var length = rootLength(path); |
| + if (length > 0) return path.substring(0, length); |
| + return isRootRelative(path) ? path[0] : null; |
| + } |
| - /// Gets the root prefix of [path] if it's root-relative. |
| + /// 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.
|
| /// |
| - /// If [path] is relative or absolute and not root-relative, returns `null`. |
| - String getRelativeRoot(String path); |
| + /// If [path] is relative or absolute and not root-relative, returns `false`. |
| + bool isRootRelative(String path); |
| /// Returns the path represented by [uri] in this style. |
| String pathFromUri(Uri uri); |