mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Auto merge of #116606 - ChrisDenton:empty, r=dtolnay
On Windows make `read_dir` error on the empty path This makes Windows consistent with other platforms. Note that this should not be taken to imply any decision on #114149 has been taken. However it was felt that while there is a lack of libs-api consensus, we should be consistent across platforms in the meantime. This is a change in behaviour for Windows so will also need an fcp before merging. r? libs-api
This commit is contained in:
commit
aec4741d42
@ -1066,6 +1066,14 @@ impl DirBuilder {
|
||||
}
|
||||
|
||||
pub fn readdir(p: &Path) -> io::Result<ReadDir> {
|
||||
// We push a `*` to the end of the path which cause the empty path to be
|
||||
// treated as the current directory. So, for consistency with other platforms,
|
||||
// we explicitly error on the empty path.
|
||||
if p.as_os_str().is_empty() {
|
||||
// Return an error code consistent with other ways of opening files.
|
||||
// E.g. fs::metadata or File::open.
|
||||
return Err(io::Error::from_raw_os_error(c::ERROR_PATH_NOT_FOUND as i32));
|
||||
}
|
||||
let root = p.to_path_buf();
|
||||
let star = p.join("*");
|
||||
let path = maybe_verbatim(&star)?;
|
||||
|
Loading…
Reference in New Issue
Block a user