Skip to content

Commit 683db28

Browse files
authored
Merge pull request #1440 from rivy/fix.win-legacy
Fix for legacy Windows versions
2 parents 7df7c14 + 95809ae commit 683db28

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ unix = [
3939
"generic"
4040
]
4141
windows = ["generic"]
42+
windows_legacy = [
43+
"arch",
44+
"nproc",
45+
"sync",
46+
"touch",
47+
"whoami",
48+
49+
"redox_generic"
50+
]
4251
# Feature "fuchsia" contains the exclusive list of utilities
4352
# that can be compiled and run on Fuchsia. Should be built
4453
# with --no-default-features when selecting this feature.

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub fn main() {
1616
if val == "1" && key.starts_with(feature_prefix) {
1717
let krate = key[feature_prefix.len()..].to_lowercase();
1818
match krate.as_ref() {
19-
"default" | "unix" | "redox" | "redox_generic" | "fuchsia" | "generic" | "windows"
19+
"default" | "unix" | "redox" | "redox_generic" | "fuchsia" | "generic" | "windows" | "windows_legacy"
2020
| "nightly" | "test_unimplemented" => continue,
2121
_ => {}
2222
}

src/cp/cp.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ extern crate kernel32;
2929
#[cfg(windows)]
3030
use kernel32::GetFileInformationByHandle;
3131
#[cfg(windows)]
32-
use kernel32::CreateFile2;
32+
use kernel32::CreateFileW;
3333
#[cfg(windows)]
3434
extern crate winapi;
3535

@@ -731,10 +731,12 @@ fn preserve_hardlinks(
731731
#[cfg(windows)]
732732
{
733733
let stat = mem::uninitialized();
734-
let handle = CreateFile2(
734+
let handle = CreateFileW(
735735
src_path.as_ptr() as *const u16,
736736
winapi::um::winnt::GENERIC_READ,
737737
winapi::um::winnt::FILE_SHARE_READ,
738+
std::ptr::null_mut(),
739+
0,
738740
0,
739741
std::ptr::null_mut(),
740742
);

0 commit comments

Comments
 (0)