File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,12 @@ pub fn is_verbatim_sep(b: u8) -> bool {
22
22
b == b'\\'
23
23
}
24
24
25
+ // In most DOS systems, it is not possible to have more than 26 drive letters.
26
+ // See <https://en.wikipedia.org/wiki/Drive_letter_assignment#Common_assignments>.
27
+ pub fn is_valid_drive_letter ( disk : u8 ) -> bool {
28
+ disk. is_ascii_alphabetic ( )
29
+ }
30
+
25
31
pub fn parse_prefix ( path : & OsStr ) -> Option < Prefix < ' _ > > {
26
32
use crate :: path:: Prefix :: * ;
27
33
unsafe {
@@ -52,7 +58,7 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix<'_>> {
52
58
let idx = path. iter ( ) . position ( |& b| b == b'\\' ) ;
53
59
if idx == Some ( 2 ) && path[ 1 ] == b':' {
54
60
let c = path[ 0 ] ;
55
- if c . is_ascii ( ) && ( c as char ) . is_alphabetic ( ) {
61
+ if is_valid_drive_letter ( c ) {
56
62
// \\?\C:\ path
57
63
return Some ( VerbatimDisk ( c. to_ascii_uppercase ( ) ) ) ;
58
64
}
@@ -77,7 +83,7 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix<'_>> {
77
83
} else if path. get ( 1 ) == Some ( & b':' ) {
78
84
// C:
79
85
let c = path[ 0 ] ;
80
- if c . is_ascii ( ) && ( c as char ) . is_alphabetic ( ) {
86
+ if is_valid_drive_letter ( c ) {
81
87
return Some ( Disk ( c. to_ascii_uppercase ( ) ) ) ;
82
88
}
83
89
}
You can’t perform that action at this time.
0 commit comments