@@ -41,8 +41,8 @@ pub struct FileAttr {
4141
4242#[ derive( Copy , Clone , PartialEq , Eq , Hash , Debug ) ]
4343pub struct FileType {
44- attributes : u32 ,
45- reparse_tag : u32 ,
44+ is_directory : bool ,
45+ is_symlink : bool ,
4646}
4747
4848pub struct ReadDir {
@@ -1111,32 +1111,29 @@ impl FileTimes {
11111111}
11121112
11131113impl FileType {
1114- fn new ( attrs : u32 , reparse_tag : u32 ) -> FileType {
1115- FileType { attributes : attrs, reparse_tag }
1114+ fn new ( attributes : u32 , reparse_tag : u32 ) -> FileType {
1115+ let is_directory = attributes & c:: FILE_ATTRIBUTE_DIRECTORY != 0 ;
1116+ let is_symlink = {
1117+ let is_reparse_point = attributes & c:: FILE_ATTRIBUTE_REPARSE_POINT != 0 ;
1118+ let is_reparse_tag_name_surrogate = reparse_tag & 0x20000000 != 0 ;
1119+ is_reparse_point && is_reparse_tag_name_surrogate
1120+ } ;
1121+ FileType { is_directory, is_symlink }
11161122 }
11171123 pub fn is_dir ( & self ) -> bool {
1118- !self . is_symlink ( ) && self . is_directory ( )
1124+ !self . is_symlink && self . is_directory
11191125 }
11201126 pub fn is_file ( & self ) -> bool {
1121- !self . is_symlink ( ) && !self . is_directory ( )
1127+ !self . is_symlink && !self . is_directory
11221128 }
11231129 pub fn is_symlink ( & self ) -> bool {
1124- self . is_reparse_point ( ) && self . is_reparse_tag_name_surrogate ( )
1130+ self . is_symlink
11251131 }
11261132 pub fn is_symlink_dir ( & self ) -> bool {
1127- self . is_symlink ( ) && self . is_directory ( )
1133+ self . is_symlink && self . is_directory
11281134 }
11291135 pub fn is_symlink_file ( & self ) -> bool {
1130- self . is_symlink ( ) && !self . is_directory ( )
1131- }
1132- fn is_directory ( & self ) -> bool {
1133- self . attributes & c:: FILE_ATTRIBUTE_DIRECTORY != 0
1134- }
1135- fn is_reparse_point ( & self ) -> bool {
1136- self . attributes & c:: FILE_ATTRIBUTE_REPARSE_POINT != 0
1137- }
1138- fn is_reparse_tag_name_surrogate ( & self ) -> bool {
1139- self . reparse_tag & 0x20000000 != 0
1136+ self . is_symlink && !self . is_directory
11401137 }
11411138}
11421139
0 commit comments