Line data Source code
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
3 : // BSD-style license that can be found in the LICENSE file.
4 :
5 : import 'characters.dart' as chars;
6 :
7 : /// Returns whether [char] is the code for an ASCII letter (uppercase or
8 : /// lowercase).
9 : bool isAlphabetic(int char) =>
10 0 : (char >= chars.UPPER_A && char <= chars.UPPER_Z) ||
11 0 : (char >= chars.LOWER_A && char <= chars.LOWER_Z);
12 :
13 : /// Returns whether [char] is the code for an ASCII digit.
14 0 : bool isNumeric(int char) => char >= chars.ZERO && char <= chars.NINE;
15 :
16 : /// Returns whether [path] has a URL-formatted Windows drive letter beginning at
17 : /// [index].
18 : bool isDriveLetter(String path, int index) {
19 0 : if (path.length < index + 2) return false;
20 0 : if (!isAlphabetic(path.codeUnitAt(index))) return false;
21 0 : if (path.codeUnitAt(index + 1) != chars.COLON) return false;
22 0 : if (path.length == index + 2) return true;
23 0 : return path.codeUnitAt(index + 2) == chars.SLASH;
24 : }
|