Skip to content

Commit 8975a6d

Browse files
committed
Win: Remove special casing of the win7 target for std::fs::rename
1 parent e2bb094 commit 8975a6d

File tree

1 file changed

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

1 file changed

+1
-14
lines changed

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

+1-14
Original file line numberDiff line numberDiff line change
@@ -1188,11 +1188,7 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
11881188
// SAFETY: We have allocated enough memory for a full FILE_RENAME_INFO struct and a filename.
11891189
unsafe {
11901190
(&raw mut (*file_rename_info).Anonymous).write(c::FILE_RENAME_INFO_0 {
1191-
// Don't bother with FileRenameInfo on Windows 7 since it doesn't exist.
1192-
#[cfg(not(target_vendor = "win7"))]
11931191
Flags: c::FILE_RENAME_FLAG_REPLACE_IF_EXISTS | c::FILE_RENAME_FLAG_POSIX_SEMANTICS,
1194-
#[cfg(target_vendor = "win7")]
1195-
ReplaceIfExists: 1,
11961192
});
11971193

11981194
(&raw mut (*file_rename_info).RootDirectory).write(ptr::null_mut());
@@ -1202,22 +1198,16 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
12021198
.copy_to_nonoverlapping((&raw mut (*file_rename_info).FileName) as *mut u16, new.len());
12031199
}
12041200

1205-
#[cfg(not(target_vendor = "win7"))]
1206-
const FileInformationClass: c::FILE_INFO_BY_HANDLE_CLASS = c::FileRenameInfoEx;
1207-
#[cfg(target_vendor = "win7")]
1208-
const FileInformationClass: c::FILE_INFO_BY_HANDLE_CLASS = c::FileRenameInfo;
1209-
12101201
// We don't use `set_file_information_by_handle` here as `FILE_RENAME_INFO` is used for both `FileRenameInfo` and `FileRenameInfoEx`.
12111202
let result = unsafe {
12121203
cvt(c::SetFileInformationByHandle(
12131204
handle.as_raw_handle(),
1214-
FileInformationClass,
1205+
c::FileRenameInfoEx,
12151206
(&raw const *file_rename_info).cast::<c_void>(),
12161207
struct_size,
12171208
))
12181209
};
12191210

1220-
#[cfg(not(target_vendor = "win7"))]
12211211
if let Err(err) = result {
12221212
if err.raw_os_error() == Some(c::ERROR_INVALID_PARAMETER as _) {
12231213
// FileRenameInfoEx and FILE_RENAME_FLAG_POSIX_SEMANTICS were added in Windows 10 1607; retry with FileRenameInfo.
@@ -1236,9 +1226,6 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> {
12361226
}
12371227
}
12381228

1239-
#[cfg(target_vendor = "win7")]
1240-
result?;
1241-
12421229
Ok(())
12431230
}
12441231

0 commit comments

Comments
 (0)