@@ -1582,7 +1582,7 @@ mod remove_dir_impl {
1582
1582
// Modern implementation using openat(), unlinkat() and fdopendir()
1583
1583
#[ cfg( not( any( all( target_os = "macos" , target_arch = "x86_64" ) , target_os = "redox" ) ) ) ]
1584
1584
mod remove_dir_impl {
1585
- use super :: { cstr, lstat, Dir , InnerReadDir , ReadDir } ;
1585
+ use super :: { cstr, lstat, Dir , DirEntry , InnerReadDir , ReadDir } ;
1586
1586
use crate :: ffi:: CStr ;
1587
1587
use crate :: io;
1588
1588
use crate :: os:: unix:: io:: { AsRawFd , FromRawFd , IntoRawFd } ;
@@ -1629,6 +1629,30 @@ mod remove_dir_impl {
1629
1629
) )
1630
1630
}
1631
1631
1632
+ #[ cfg( any(
1633
+ target_os = "solaris" ,
1634
+ target_os = "illumos" ,
1635
+ target_os = "haiku" ,
1636
+ target_os = "vxworks"
1637
+ ) ) ]
1638
+ fn is_dir ( _ent : & DirEntry ) -> Option < bool > {
1639
+ None
1640
+ }
1641
+
1642
+ #[ cfg( not( any(
1643
+ target_os = "solaris" ,
1644
+ target_os = "illumos" ,
1645
+ target_os = "haiku" ,
1646
+ target_os = "vxworks"
1647
+ ) ) ) ]
1648
+ fn is_dir ( ent : & DirEntry ) -> Option < bool > {
1649
+ match ent. entry . d_type {
1650
+ libc:: DT_UNKNOWN => None ,
1651
+ libc:: DT_DIR => Some ( true ) ,
1652
+ _ => Some ( false ) ,
1653
+ }
1654
+ }
1655
+
1632
1656
fn remove_dir_all_recursive ( parent_fd : Option < RawFd > , p : & Path ) -> io:: Result < ( ) > {
1633
1657
let pcstr = cstr ( p) ?;
1634
1658
@@ -1639,22 +1663,7 @@ mod remove_dir_impl {
1639
1663
let ( dir, fd) = fdreaddir ( fd) ?;
1640
1664
for child in dir {
1641
1665
let child = child?;
1642
- let child_is_dir = if cfg ! ( any(
1643
- target_os = "solaris" ,
1644
- target_os = "illumos" ,
1645
- target_os = "haiku" ,
1646
- target_os = "vxworks"
1647
- ) ) {
1648
- // no d_type in dirent
1649
- None
1650
- } else {
1651
- match child. entry . d_type {
1652
- libc:: DT_UNKNOWN => None ,
1653
- libc:: DT_DIR => Some ( true ) ,
1654
- _ => Some ( false ) ,
1655
- }
1656
- } ;
1657
- match child_is_dir {
1666
+ match is_dir ( & child) {
1658
1667
Some ( true ) => {
1659
1668
remove_dir_all_recursive ( Some ( fd) , Path :: new ( & child. file_name ( ) ) ) ?;
1660
1669
}
0 commit comments