Closed
Description
I tried this code:
fn main() {
fs::create_dir("dir").unwrap();
File::create("dir/file").unwrap();
for e in read_dir("dir").unwrap() {
let e = e.unwrap();
let p = e.path();
let ft1 = e.file_type().unwrap();
let ft2 = p.metadata().unwrap().file_type();
assert_eq!(ft1, ft2);
}
}
This currently fails, even though no symlinks are involved.
This is because FileType
on Unix are currently compared on the totality of their contained unix st_mode
, which are bitflags of the form ...YYY0XXX
(in octal) where XXX
is a Unix permission mode and ...YYY
the actual file type. As of now, depending on how the FileType
is built, XXX
may be either 000
(from DirEntry::filetype
) or set to the actual file permission mode (if built from fs::metadata
).
(This bug was co-investigated with @hernoufM)