Closed
Description
This was reported on discord by @Fulgen301 who pointed out that the C++ STL has a similar issue.
Example:
// where `path` is a path to an empty volume.
let path = r"\\?\Volume{e6d42597-fcdc-4856-b3c2-482fe652f1df}\";
std::fs::read_dir(path).unwrap();
prints:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "The system cannot find the file specified." }
It should return success but the returned iterator will have no items.
Basically if you use FindFirstFileW
on a completely empty volume then it will return ERROR_FILE_NOT_FOUND
. Rust should interpret this as being an empty iteration and not return an error to the user. Note that empty directories do not return an error so this behaviour was overlooked.
We need to add some extra logic to this else
:
rust/library/std/src/sys/pal/windows/fs.rs
Lines 1077 to 1079 in 6ed31ab