Skip to content

Commit da4c8c0

Browse files
Fulgen301gitbot
authored and
gitbot
committed
Win: Remove special casing of the win7 target for std::fs::rename
1 parent 89d2548 commit da4c8c0

File tree

1 file changed

+1
-14
lines changed
  • std/src/sys/pal/windows

1 file changed

+1
-14
lines changed

std/src/sys/pal/windows/fs.rs

+1-14
Original file line numberDiff line numberDiff line change
@@ -1316,11 +1316,7 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
13161316
// SAFETY: We have allocated enough memory for a full FILE_RENAME_INFO struct and a filename.
13171317
unsafe {
13181318
(&raw mut (*file_rename_info).Anonymous).write(c::FILE_RENAME_INFO_0 {
1319-
// Don't bother with FileRenameInfo on Windows 7 since it doesn't exist.
1320-
#[cfg(not(target_vendor = "win7"))]
13211319
Flags: c::FILE_RENAME_FLAG_REPLACE_IF_EXISTS | c::FILE_RENAME_FLAG_POSIX_SEMANTICS,
1322-
#[cfg(target_vendor = "win7")]
1323-
ReplaceIfExists: 1,
13241320
});
13251321

13261322
(&raw mut (*file_rename_info).RootDirectory).write(ptr::null_mut());
@@ -1330,22 +1326,16 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
13301326
.copy_to_nonoverlapping((&raw mut (*file_rename_info).FileName) as *mut u16, new.len());
13311327
}
13321328

1333-
#[cfg(not(target_vendor = "win7"))]
1334-
const FileInformationClass: c::FILE_INFO_BY_HANDLE_CLASS = c::FileRenameInfoEx;
1335-
#[cfg(target_vendor = "win7")]
1336-
const FileInformationClass: c::FILE_INFO_BY_HANDLE_CLASS = c::FileRenameInfo;
1337-
13381329
// We don't use `set_file_information_by_handle` here as `FILE_RENAME_INFO` is used for both `FileRenameInfo` and `FileRenameInfoEx`.
13391330
let result = unsafe {
13401331
cvt(c::SetFileInformationByHandle(
13411332
handle.as_raw_handle(),
1342-
FileInformationClass,
1333+
c::FileRenameInfoEx,
13431334
(&raw const *file_rename_info).cast::<c_void>(),
13441335
struct_size,
13451336
))
13461337
};
13471338

1348-
#[cfg(not(target_vendor = "win7"))]
13491339
if let Err(err) = result {
13501340
if err.raw_os_error() == Some(c::ERROR_INVALID_PARAMETER as _) {
13511341
// FileRenameInfoEx and FILE_RENAME_FLAG_POSIX_SEMANTICS were added in Windows 10 1607; retry with FileRenameInfo.
@@ -1364,9 +1354,6 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
13641354
}
13651355
}
13661356

1367-
#[cfg(target_vendor = "win7")]
1368-
result?;
1369-
13701357
Ok(())
13711358
}
13721359

0 commit comments

Comments
 (0)