@@ -216,19 +216,6 @@ impl DirEntryInner {
216
216
}
217
217
218
218
/// Returns true if and only if this entry points to a directory.
219
- ///
220
- /// This works around a bug in Rust's standard library:
221
- /// https://github.com/rust-lang/rust/issues/46484
222
- #[ cfg( windows) ]
223
- fn is_dir ( & self ) -> bool {
224
- self . metadata ( ) . map ( |md| metadata_is_dir ( & md) ) . unwrap_or ( false )
225
- }
226
-
227
- /// Returns true if and only if this entry points to a directory.
228
- ///
229
- /// This works around a bug in Rust's standard library:
230
- /// https://github.com/rust-lang/rust/issues/46484
231
- #[ cfg( not( windows) ) ]
232
219
fn is_dir ( & self ) -> bool {
233
220
self . file_type ( ) . map ( |ft| ft. is_dir ( ) ) . unwrap_or ( false )
234
221
}
@@ -253,10 +240,6 @@ struct DirEntryRaw {
253
240
ino : u64 ,
254
241
/// The underlying metadata (Windows only). We store this on Windows
255
242
/// because this comes for free while reading a directory.
256
- ///
257
- /// We use this to determine whether an entry is a directory or not, which
258
- /// works around a bug in Rust's standard library:
259
- /// https://github.com/rust-lang/rust/issues/46484
260
243
#[ cfg( windows) ]
261
244
metadata : fs:: Metadata ,
262
245
}
@@ -509,7 +492,7 @@ impl WalkBuilder {
509
492
( p. to_path_buf ( ) , None )
510
493
} else {
511
494
let mut wd = WalkDir :: new ( p) ;
512
- wd = wd. follow_links ( follow_links || path_is_file ( p ) ) ;
495
+ wd = wd. follow_links ( follow_links || p . is_file ( ) ) ;
513
496
if let Some ( max_depth) = max_depth {
514
497
wd = wd. max_depth ( max_depth) ;
515
498
}
@@ -776,7 +759,7 @@ impl Walk {
776
759
return false ;
777
760
}
778
761
779
- let is_dir = walkdir_entry_is_dir ( ent) ;
762
+ let is_dir = ent. file_type ( ) . is_dir ( ) ;
780
763
let max_size = self . max_filesize ;
781
764
let should_skip_path = skip_path ( & self . ig , ent. path ( ) , is_dir) ;
782
765
let should_skip_filesize = if !is_dir && max_size. is_some ( ) {
@@ -805,7 +788,7 @@ impl Iterator for Walk {
805
788
}
806
789
Some ( ( path, Some ( it) ) ) => {
807
790
self . it = Some ( it) ;
808
- if path_is_dir ( & path) {
791
+ if path. is_dir ( ) {
809
792
let ( ig, err) = self . ig_root . add_parents ( path) ;
810
793
self . ig = ig;
811
794
if let Some ( err) = err {
@@ -895,7 +878,7 @@ impl Iterator for WalkEventIter {
895
878
None => None ,
896
879
Some ( Err ( err) ) => Some ( Err ( err) ) ,
897
880
Some ( Ok ( dent) ) => {
898
- if walkdir_entry_is_dir ( & dent) {
881
+ if dent. file_type ( ) . is_dir ( ) {
899
882
self . depth += 1 ;
900
883
Some ( Ok ( WalkEvent :: Dir ( dent) ) )
901
884
} else {
@@ -1434,62 +1417,6 @@ fn skip_path(ig: &Ignore, path: &Path, is_dir: bool) -> bool {
1434
1417
}
1435
1418
}
1436
1419
1437
- /// Returns true if and only if this path points to a directory.
1438
- ///
1439
- /// This works around a bug in Rust's standard library:
1440
- /// https://github.com/rust-lang/rust/issues/46484
1441
- #[ cfg( windows) ]
1442
- fn path_is_dir ( path : & Path ) -> bool {
1443
- fs:: metadata ( path) . map ( |md| metadata_is_dir ( & md) ) . unwrap_or ( false )
1444
- }
1445
-
1446
- /// Returns true if and only if this entry points to a directory.
1447
- #[ cfg( not( windows) ) ]
1448
- fn path_is_dir ( path : & Path ) -> bool {
1449
- path. is_dir ( )
1450
- }
1451
-
1452
- /// Returns true if and only if this path points to a file.
1453
- ///
1454
- /// This works around a bug in Rust's standard library:
1455
- /// https://github.com/rust-lang/rust/issues/46484
1456
- #[ cfg( windows) ]
1457
- fn path_is_file ( path : & Path ) -> bool {
1458
- !path_is_dir ( path)
1459
- }
1460
-
1461
- /// Returns true if and only if this entry points to a directory.
1462
- #[ cfg( not( windows) ) ]
1463
- fn path_is_file ( path : & Path ) -> bool {
1464
- path. is_file ( )
1465
- }
1466
-
1467
- /// Returns true if and only if the given walkdir entry points to a directory.
1468
- ///
1469
- /// This works around a bug in Rust's standard library:
1470
- /// https://github.com/rust-lang/rust/issues/46484
1471
- #[ cfg( windows) ]
1472
- fn walkdir_entry_is_dir ( dent : & walkdir:: DirEntry ) -> bool {
1473
- dent. metadata ( ) . map ( |md| metadata_is_dir ( & md) ) . unwrap_or ( false )
1474
- }
1475
-
1476
- /// Returns true if and only if the given walkdir entry points to a directory.
1477
- #[ cfg( not( windows) ) ]
1478
- fn walkdir_entry_is_dir ( dent : & walkdir:: DirEntry ) -> bool {
1479
- dent. file_type ( ) . is_dir ( )
1480
- }
1481
-
1482
- /// Returns true if and only if the given metadata points to a directory.
1483
- ///
1484
- /// This works around a bug in Rust's standard library:
1485
- /// https://github.com/rust-lang/rust/issues/46484
1486
- #[ cfg( windows) ]
1487
- fn metadata_is_dir ( md : & fs:: Metadata ) -> bool {
1488
- use std:: os:: windows:: fs:: MetadataExt ;
1489
- use winapi:: um:: winnt:: FILE_ATTRIBUTE_DIRECTORY ;
1490
- md. file_attributes ( ) & FILE_ATTRIBUTE_DIRECTORY != 0
1491
- }
1492
-
1493
1420
#[ cfg( test) ]
1494
1421
mod tests {
1495
1422
use std:: fs:: { self , File } ;
0 commit comments