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 1
1
use std:: ffi:: OsString ;
2
- use std:: fs;
3
2
use std:: path:: PathBuf ;
4
3
5
- use std:: fs:: File ;
4
+ #[ cfg( unix) ]
5
+ use std:: fs:: { self , File } ;
6
+ #[ cfg( unix) ]
6
7
use std:: io:: stdin;
8
+ #[ cfg( unix) ]
7
9
use std:: os:: fd:: AsFd ;
8
10
9
11
use regex:: Regex ;
@@ -185,18 +187,21 @@ pub fn parse_params<I: IntoIterator<Item = OsString>>(opts: I) -> Result<Params,
185
187
let mut from_path: PathBuf = PathBuf :: from ( & params. from ) ;
186
188
let mut to_path: PathBuf = PathBuf :: from ( & params. to ) ;
187
189
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 ( ) ;
198
204
}
199
- params. stdin_path = stdin_path. into ( ) ;
200
205
}
201
206
202
207
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