From aac8a0a518048d6102c1342835904cfb2ebdab63 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Sat, 30 Jul 2022 05:28:38 +0100 Subject: [PATCH] Reset directory iteration in remove_dir_all --- library/std/src/sys/windows/fs.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs index 4d3162f1254..c96bcf41d51 100644 --- a/library/std/src/sys/windows/fs.rs +++ b/library/std/src/sys/windows/fs.rs @@ -1035,11 +1035,13 @@ fn copy_handle(f: &File) -> mem::ManuallyDrop { unsafe { mem::ManuallyDrop::new(File::from_raw_handle(f.as_raw_handle())) } } + let mut restart = true; while let Some(dir) = dirlist.last() { let dir = copy_handle(dir); // Fill the buffer and iterate the entries. - let more_data = dir.fill_dir_buff(&mut buffer, false)?; + let more_data = dir.fill_dir_buff(&mut buffer, restart)?; + restart = false; for (name, is_directory) in buffer.iter() { if is_directory { let child_dir = open_link_no_reparse(