This repository was archived by the owner on May 28, 2025. It is now read-only.
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 {
2222 b == b'\\'
2323}
2424
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+
2531pub fn parse_prefix ( path : & OsStr ) -> Option < Prefix < ' _ > > {
2632 use crate :: path:: Prefix :: * ;
2733 unsafe {
@@ -52,7 +58,7 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix<'_>> {
5258 let idx = path. iter ( ) . position ( |& b| b == b'\\' ) ;
5359 if idx == Some ( 2 ) && path[ 1 ] == b':' {
5460 let c = path[ 0 ] ;
55- if c . is_ascii ( ) && ( c as char ) . is_alphabetic ( ) {
61+ if is_valid_drive_letter ( c ) {
5662 // \\?\C:\ path
5763 return Some ( VerbatimDisk ( c. to_ascii_uppercase ( ) ) ) ;
5864 }
@@ -77,7 +83,7 @@ pub fn parse_prefix(path: &OsStr) -> Option<Prefix<'_>> {
7783 } else if path. get ( 1 ) == Some ( & b':' ) {
7884 // C:
7985 let c = path[ 0 ] ;
80- if c . is_ascii ( ) && ( c as char ) . is_alphabetic ( ) {
86+ if is_valid_drive_letter ( c ) {
8187 return Some ( Disk ( c. to_ascii_uppercase ( ) ) ) ;
8288 }
8389 }
You can’t perform that action at this time.
0 commit comments