@@ -5,17 +5,25 @@ use std::{
5
5
} ;
6
6
7
7
fn unixify_path ( path : & Path ) -> String {
8
- let p = path. components ( )
9
- . filter_map ( |c| Some ( match c {
10
- std:: path:: Component :: Prefix ( prefix_component) => match prefix_component. kind ( ) {
11
- Prefix :: Disk ( os_str) => format ! ( "/{}" , os_str as char ) . to_lowercase ( ) ,
12
- _ => format ! ( "{}" , prefix_component. as_os_str( ) . to_str( ) . unwrap( ) ) ,
13
- } ,
14
- std:: path:: Component :: RootDir => return None ,
15
- std:: path:: Component :: CurDir => "." . to_string ( ) ,
16
- std:: path:: Component :: ParentDir => ".." . to_string ( ) ,
17
- std:: path:: Component :: Normal ( os_str) => os_str. to_str ( ) . unwrap ( ) . replace ( " " , "\\ " ) ,
18
- } ) )
8
+ let p = path
9
+ . components ( )
10
+ . filter_map ( |c| {
11
+ Some ( match c {
12
+ std:: path:: Component :: Prefix ( prefix_component) => match prefix_component. kind ( ) {
13
+ Prefix :: Disk ( os_str) => format ! ( "/{}" , os_str as char ) . to_lowercase ( ) ,
14
+ _ => format ! ( "{}" , prefix_component. as_os_str( ) . to_str( ) . unwrap( ) ) ,
15
+ } ,
16
+ std:: path:: Component :: RootDir => return None ,
17
+ std:: path:: Component :: CurDir => "." . to_string ( ) ,
18
+ std:: path:: Component :: ParentDir => ".." . to_string ( ) ,
19
+ std:: path:: Component :: Normal ( os_str) => os_str
20
+ . to_str ( )
21
+ . unwrap ( )
22
+ . replace ( " " , "\\ " )
23
+ . replace ( '(' , "\\ (" )
24
+ . replace ( ')' , "\\ )" ) ,
25
+ } )
26
+ } )
19
27
. collect :: < Vec < _ > > ( ) ;
20
28
// eprintln!("P: {:?}", p);
21
29
p. join ( "/" )
0 commit comments