Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(606)

Unified Diff: pkg/path/lib/src/style/posix.dart

Issue 439223002: Add InternalStyle:rootLength to implement isAbsolute and rootPrefix. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/path/lib/src/style/posix.dart
diff --git a/pkg/path/lib/src/style/posix.dart b/pkg/path/lib/src/style/posix.dart
index b8b82b406d33f31a08d5c4a05c67b86dbdbc4b2f..30278245400909ce685b18e2ccc60c16b3fa3c76 100644
--- a/pkg/path/lib/src/style/posix.dart
+++ b/pkg/path/lib/src/style/posix.dart
@@ -30,8 +30,14 @@ class PosixStyle extends InternalStyle {
bool needsSeparator(String path) =>
path.isNotEmpty && !isSeparator(path.codeUnitAt(path.length - 1));
+ int rootLength(String path) {
+ if (path.isNotEmpty && isSeparator(path.codeUnitAt(0))) return 1;
+ return 0;
+ }
+
String getRoot(String path) {
- if (path.isNotEmpty && isSeparator(path.codeUnitAt(0))) return '/';
+ int length = rootLength(path);
Bob Nystrom 2014/08/04 17:17:32 int -> var, here and elsewhere. We don't type anno
Anders Johnsen 2014/08/05 08:57:13 Done.
+ if (length > 0) return path.substring(0, length);
return null;
}

Powered by Google App Engine
This is Rietveld 408576698