Auto merge of #150516 - Ayush1325:uefi-fs-readdir-fix, r=jhpratt
std: sys: fs: uefi: Ignore "." and ".." when reading directory - At least in Unix, "." and ".." are not returned as a directory entry. So ignore these in UEFI as well. - Will also allow using the `remove_dir_all` implementation from `sys/fs/common`.
This commit is contained in:
commit
ab32c26b49
1 changed files with 9 additions and 1 deletions
|
|
@ -160,7 +160,15 @@ impl Iterator for ReadDir {
|
|||
fn next(&mut self) -> Option<io::Result<DirEntry>> {
|
||||
match self.0.read_dir_entry() {
|
||||
Ok(None) => None,
|
||||
Ok(Some(x)) => Some(Ok(DirEntry::from_uefi(x, self.0.path()))),
|
||||
Ok(Some(x)) => {
|
||||
let temp = DirEntry::from_uefi(x, self.0.path());
|
||||
// Ignore "." and "..". This is how ReadDir behaves in Unix.
|
||||
if temp.file_name == "." || temp.file_name == ".." {
|
||||
self.next()
|
||||
} else {
|
||||
Some(Ok(temp))
|
||||
}
|
||||
}
|
||||
Err(e) => Some(Err(e)),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue