File tree 2 files changed +7
-4
lines changed
library/std/src/sys/windows
2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -313,6 +313,9 @@ pub(crate) fn make_bat_command_line(
313
313
///
314
314
/// This is necessary because cmd.exe does not support verbatim paths.
315
315
pub ( crate ) fn to_user_path ( path : & Path ) -> io:: Result < Vec < u16 > > {
316
+ from_wide_to_user_path ( to_u16s ( path) ?)
317
+ }
318
+ pub ( crate ) fn from_wide_to_user_path ( mut path : Vec < u16 > ) -> io:: Result < Vec < u16 > > {
316
319
use crate :: ptr;
317
320
use crate :: sys:: windows:: fill_utf16_buf;
318
321
@@ -325,8 +328,6 @@ pub(crate) fn to_user_path(path: &Path) -> io::Result<Vec<u16>> {
325
328
const N : u16 = b'N' as _ ;
326
329
const C : u16 = b'C' as _ ;
327
330
328
- let mut path = to_u16s ( path) ?;
329
-
330
331
// Early return if the path is too long to remove the verbatim prefix.
331
332
const LEGACY_MAX_PATH : usize = 260 ;
332
333
if path. len ( ) > LEGACY_MAX_PATH {
Original file line number Diff line number Diff line change @@ -542,8 +542,10 @@ impl File {
542
542
// Turn `\??\` into `\\?\` (a verbatim path).
543
543
subst[ 1 ] = b'\\' as u16 ;
544
544
// Attempt to convert to a more user-friendly path.
545
- let user = super :: args:: to_user_path ( subst. iter ( ) . copied ( ) . chain ( [ 0 ] ) . collect ( ) ) ?;
546
- Ok ( PathBuf :: from ( OsString :: from_wide ( & user) ) )
545
+ let user = super :: args:: from_wide_to_user_path (
546
+ subst. iter ( ) . copied ( ) . chain ( [ 0 ] ) . collect ( ) ,
547
+ ) ?;
548
+ Ok ( PathBuf :: from ( OsString :: from_wide ( & user. strip_suffix ( & [ 0 ] ) . unwrap_or ( & user) ) ) )
547
549
} else {
548
550
Ok ( PathBuf :: from ( OsString :: from_wide ( subst) ) )
549
551
}
You can’t perform that action at this time.
0 commit comments