File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed
Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use std::path::PathBuf;
44
55use std:: fs:: File ;
66use std:: io:: stdin;
7+ #[ cfg( unix) ]
78use std:: os:: fd:: AsFd ;
89
910use regex:: Regex ;
@@ -185,18 +186,21 @@ pub fn parse_params<I: IntoIterator<Item = OsString>>(opts: I) -> Result<Params,
185186 let mut from_path: PathBuf = PathBuf :: from ( & params. from ) ;
186187 let mut to_path: PathBuf = PathBuf :: from ( & params. to ) ;
187188
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 ( ) ) ;
189+ #[ cfg( unix) ]
190+ {
191+ // check if stdin is a directory
192+ let fd = stdin ( ) . as_fd ( ) . try_clone_to_owned ( ) . unwrap ( ) ;
193+ let file = File :: from ( fd) ;
194+ let meta = file. metadata ( ) . unwrap ( ) ;
195+ if meta. is_dir ( ) {
196+ let mut stdin_path = fs:: canonicalize ( "/dev/stdin" ) . unwrap ( ) ;
197+ if params. from == "-" {
198+ stdin_path. push ( to_path. file_name ( ) . unwrap ( ) ) ;
199+ } else {
200+ stdin_path. push ( from_path. file_name ( ) . unwrap ( ) ) ;
201+ }
202+ params. stdin_path = stdin_path. into ( ) ;
198203 }
199- params. stdin_path = stdin_path. into ( ) ;
200204 }
201205
202206 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