os: fix normalize_drive_letter (used by os.real_path) returning a parameter

pull/10506/head
Delyan Angelov 2021-06-18 12:56:58 +03:00
parent a01e8eb0f8
commit b7fea87d07
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 9 additions and 8 deletions

View File

@ -799,17 +799,19 @@ pub fn real_path(fpath string) string {
} }
res = unsafe { fullpath.vstring() } res = unsafe { fullpath.vstring() }
} }
return normalize_drive_letter(res) unsafe { normalize_drive_letter(res) }
return res
} }
[direct_array_access; manualfree] [direct_array_access; manualfree; unsafe]
fn normalize_drive_letter(path string) string { fn normalize_drive_letter(path string) {
// normalize_drive_letter is needed, because a path like c:\nv\.bin (note the small `c`)
// in %PATH is NOT recognized by cmd.exe (and probably other programs too)...
// Capital drive letters do work fine.
$if !windows { $if !windows {
return path return
} }
// normalize_drive_letter is needed, because
// a path like c:\nv\.bin (note the small `c`) in %PATH,
// is NOT recognized by cmd.exe (and probably other programs too)...
// Capital drive letters do work fine.
if path.len > 2 && path[0] >= `a` && path[0] <= `z` && path[1] == `:` if path.len > 2 && path[0] >= `a` && path[0] <= `z` && path[1] == `:`
&& path[2] == path_separator[0] { && path[2] == path_separator[0] {
unsafe { unsafe {
@ -817,7 +819,6 @@ fn normalize_drive_letter(path string) string {
(*x) = *x - 32 (*x) = *x - 32
} }
} }
return path
} }
// fork will fork the current system process and return the pid of the fork. // fork will fork the current system process and return the pid of the fork.