@@ -4,6 +4,9 @@ use std::fs::File;
4
4
use std:: io:: { self , BufRead , BufReader , Read } ;
5
5
use std:: path:: { Path , PathBuf } ;
6
6
7
+ #[ cfg( target_family = "unix" ) ]
8
+ use std:: os:: unix:: fs:: FileTypeExt ;
9
+
7
10
use clircle:: { Clircle , Identifier } ;
8
11
use content_inspector:: { self , ContentType } ;
9
12
@@ -218,10 +221,18 @@ impl<'a> Input<'a> {
218
221
reader : {
219
222
let mut file = File :: open ( & path)
220
223
. map_err ( |e| format ! ( "'{}': {}" , path. to_string_lossy( ) , e) ) ?;
221
- if file. metadata ( ) ?. is_dir ( ) {
224
+ let metadata = file. metadata ( ) ?;
225
+ if metadata. is_dir ( ) {
222
226
return Err ( format ! ( "'{}' is a directory." , path. to_string_lossy( ) ) . into ( ) ) ;
223
227
}
224
228
229
+ #[ cfg( target_family = "unix" ) ]
230
+ if metadata. file_type ( ) . is_block_device ( ) {
231
+ return Err (
232
+ format ! ( "'{}' is a block device." , path. to_string_lossy( ) ) . into ( )
233
+ ) ;
234
+ }
235
+
225
236
if let Some ( stdout) = stdout_identifier {
226
237
let input_identifier = Identifier :: try_from ( file) . map_err ( |e| {
227
238
format ! ( "{}: Error identifying file: {}" , path. to_string_lossy( ) , e)
0 commit comments