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 0 : bool isAlphabetic(int char) => 10 0 : (char >= chars.upperA && char <= chars.upperZ) || 11 0 : (char >= chars.lowerA && char <= chars.lowerZ); 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 0 : 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 : }