Skip to content

Commit 64a8af9

Browse files
committed
Use posix_delete on windows
1 parent b616d7b commit 64a8af9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/bootstrap/lib.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,16 @@ impl Build {
14251425
if src == dst {
14261426
return;
14271427
}
1428-
let _ = fs::remove_file(&dst);
1428+
#[cfg(windows)]
1429+
{
1430+
if let Ok(file) = std::sys::fs::File::open(dst, &std::sys::fs::OpenOptions::new()) {
1431+
let _ = file.posix_delete();
1432+
}
1433+
}
1434+
#[cfg(not(windows))]
1435+
{
1436+
let _ = fs::remove_file(&dst);
1437+
}
14291438
let metadata = t!(src.symlink_metadata());
14301439
if metadata.file_type().is_symlink() {
14311440
let link = t!(fs::read_link(src));

0 commit comments

Comments
 (0)