@@ -522,21 +522,27 @@ impl FileType {
522
522
reparse_tag : reparse_tag,
523
523
}
524
524
}
525
-
526
525
pub fn is_dir ( & self ) -> bool {
527
- self . attributes & c :: FILE_ATTRIBUTE_DIRECTORY != 0
526
+ ! self . is_symlink ( ) && self . is_directory ( )
528
527
}
529
528
pub fn is_file ( & self ) -> bool {
530
- self . attributes & c :: FILE_ATTRIBUTE_DIRECTORY == 0
529
+ ! self . is_symlink ( ) && ! self . is_directory ( )
531
530
}
532
531
pub fn is_symlink ( & self ) -> bool {
533
- self . is_reparse_point ( ) && (
534
- self . reparse_tag == c:: IO_REPARSE_TAG_SYMLINK ||
535
- self . reparse_tag == c:: IO_REPARSE_TAG_MOUNT_POINT )
532
+ self . is_reparse_point ( ) && self . is_reparse_tag_name_surrogate ( )
533
+ }
534
+ pub fn is_symlink_dir ( & self ) -> bool {
535
+ self . is_symlink ( ) && self . is_directory ( )
536
+ }
537
+ fn is_directory ( & self ) -> bool {
538
+ self . attributes & c:: FILE_ATTRIBUTE_DIRECTORY != 0
536
539
}
537
- pub fn is_reparse_point ( & self ) -> bool {
540
+ fn is_reparse_point ( & self ) -> bool {
538
541
self . attributes & c:: FILE_ATTRIBUTE_REPARSE_POINT != 0
539
542
}
543
+ fn is_reparse_tag_name_surrogate ( & self ) -> bool {
544
+ self . reparse_tag & 0x20000000 != 0
545
+ }
540
546
}
541
547
542
548
impl DirBuilder {
@@ -607,12 +613,10 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> {
607
613
for child in readdir ( path) ? {
608
614
let child = child?;
609
615
let child_type = child. file_type ( ) ?;
610
- if child_type. is_dir ( ) {
611
- if child_type. is_reparse_point ( ) {
612
- rmdir ( & child. path ( ) ) ?;
613
- } else {
614
- remove_dir_all_recursive ( & child. path ( ) ) ?;
615
- }
616
+ if child_type. is_symlink_dir ( ) {
617
+ rmdir ( & child. path ( ) ) ?;
618
+ } else if child_type. is_dir ( ) {
619
+ remove_dir_all_recursive ( & child. path ( ) ) ?;
616
620
} else {
617
621
unlink ( & child. path ( ) ) ?;
618
622
}
0 commit comments