File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff line change 11use std:: ffi:: OsString ;
2- use std:: fs;
32use std:: path:: PathBuf ;
43
5- use std:: fs:: File ;
4+ #[ cfg( unix) ]
5+ use std:: fs:: { self , File } ;
6+ #[ cfg( unix) ]
67use std:: io:: stdin;
8+ #[ cfg( unix) ]
79use std:: os:: fd:: AsFd ;
810
911use regex:: Regex ;
@@ -185,18 +187,21 @@ pub fn parse_params<I: IntoIterator<Item = OsString>>(opts: I) -> Result<Params,
185187 let mut from_path: PathBuf = PathBuf :: from ( & params. from ) ;
186188 let mut to_path: PathBuf = PathBuf :: from ( & params. to ) ;
187189
188- // check if stdin is a directory
189- let fd = stdin ( ) . as_fd ( ) . try_clone_to_owned ( ) . unwrap ( ) ;
190- let file = File :: from ( fd) ;
191- let meta = file. metadata ( ) . unwrap ( ) ;
192- if meta. is_dir ( ) {
193- let mut stdin_path = fs:: canonicalize ( "/dev/stdin" ) . unwrap ( ) ;
194- if params. from == "-" {
195- stdin_path. push ( to_path. file_name ( ) . unwrap ( ) ) ;
196- } else {
197- stdin_path. push ( from_path. file_name ( ) . unwrap ( ) ) ;
190+ #[ cfg( unix) ]
191+ {
192+ // check if stdin is a directory
193+ let fd = stdin ( ) . as_fd ( ) . try_clone_to_owned ( ) . unwrap ( ) ;
194+ let file = File :: from ( fd) ;
195+ let meta = file. metadata ( ) . unwrap ( ) ;
196+ if meta. is_dir ( ) {
197+ let mut stdin_path = fs:: canonicalize ( "/dev/stdin" ) . unwrap ( ) ;
198+ if params. from == "-" {
199+ stdin_path. push ( to_path. file_name ( ) . unwrap ( ) ) ;
200+ } else {
201+ stdin_path. push ( from_path. file_name ( ) . unwrap ( ) ) ;
202+ }
203+ params. stdin_path = stdin_path. into ( ) ;
198204 }
199- params. stdin_path = stdin_path. into ( ) ;
200205 }
201206
202207 if ( from_path. is_dir ( ) || !params. stdin_path . is_empty ( ) ) && to_path. is_file ( ) {
You can’t perform that action at this time.
0 commit comments