Index: packages/path/lib/src/utils.dart |
diff --git a/packages/path/lib/src/utils.dart b/packages/path/lib/src/utils.dart |
index e32074950e7a197bf2dca44f9e3ad47bad2a3eba..3d71e560e7627ab7d8c07444be000360482027f8 100644 |
--- a/packages/path/lib/src/utils.dart |
+++ b/packages/path/lib/src/utils.dart |
@@ -2,8 +2,6 @@ |
// for details. All rights reserved. Use of this source code is governed by a |
// BSD-style license that can be found in the LICENSE file. |
-library path.utils; |
- |
import 'characters.dart' as chars; |
/// Returns whether [char] is the code for an ASCII letter (uppercase or |
@@ -14,3 +12,13 @@ bool isAlphabetic(int char) => |
/// Returns whether [char] is the code for an ASCII digit. |
bool isNumeric(int char) => char >= chars.ZERO && char <= chars.NINE; |
+ |
+/// Returns whether [path] has a URL-formatted Windows drive letter beginning at |
+/// [index]. |
+bool isDriveLetter(String path, int index) { |
+ if (path.length < index + 2) return false; |
+ if (!isAlphabetic(path.codeUnitAt(index))) return false; |
+ if (path.codeUnitAt(index + 1) != chars.COLON) return false; |
+ if (path.length == index + 2) return true; |
+ return path.codeUnitAt(index + 2) == chars.SLASH; |
+} |