Skip to content

Commit 2acfc4e

Browse files
seritoolsmbilker
authored andcommitted
Stub CreateHardLinkW to Err gracefully if unsupported
Used in `std::fs::hard_link`.
1 parent 835a8f3 commit 2acfc4e

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

library/std/src/sys/windows/c.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,17 @@ compat_fn_with_fallback! {
507507
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD);
508508
FALSE
509509
}
510+
511+
// >= 2000
512+
// https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createhardlinkw
513+
pub fn CreateHardLinkW(
514+
lpSymlinkFileName: LPCWSTR,
515+
lpTargetFileName: LPCWSTR,
516+
lpSecurityAttributes: LPSECURITY_ATTRIBUTES
517+
) -> BOOL {
518+
SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD);
519+
FALSE
520+
}
510521
}
511522

512523
compat_fn_optional! {

library/std/src/sys/windows/c/windows_sys.lst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2207,7 +2207,6 @@ Windows.Win32.Storage.FileSystem.CREATE_ALWAYS
22072207
Windows.Win32.Storage.FileSystem.CREATE_NEW
22082208
Windows.Win32.Storage.FileSystem.CreateDirectoryW
22092209
Windows.Win32.Storage.FileSystem.CreateFileW
2210-
Windows.Win32.Storage.FileSystem.CreateHardLinkW
22112210
Windows.Win32.Storage.FileSystem.DELETE
22122211
Windows.Win32.Storage.FileSystem.DeleteFileW
22132212
Windows.Win32.Storage.FileSystem.FILE_ACCESS_RIGHTS

library/std/src/sys/windows/c/windows_sys.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ extern "system" {
6565
) -> HANDLE;
6666
}
6767
#[link(name = "kernel32")]
68-
extern "system" {
69-
pub fn CreateHardLinkW(
70-
lpfilename: PCWSTR,
71-
lpexistingfilename: PCWSTR,
72-
lpsecurityattributes: *const SECURITY_ATTRIBUTES,
73-
) -> BOOL;
74-
}
75-
#[link(name = "kernel32")]
7668
extern "system" {
7769
pub fn CreateNamedPipeW(
7870
lpname: PCWSTR,

0 commit comments

Comments
 (0)