Skip to content

Commit 5466e9f

Browse files
committed
std: win: Don't expose link() on UWP
Or rather expose it, but always return an error
1 parent 0f15466 commit 5466e9f

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/libstd/sys/windows/c.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,10 @@ ifdef! {
671671
pub fn SetHandleInformation(hObject: HANDLE,
672672
dwMask: DWORD,
673673
dwFlags: DWORD) -> BOOL;
674+
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
675+
lpTargetFileName: LPCWSTR,
676+
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
677+
-> BOOL;
674678
}
675679
}
676680

@@ -885,10 +889,6 @@ extern "system" {
885889
lpOverlapped: LPOVERLAPPED)
886890
-> BOOL;
887891
pub fn CloseHandle(hObject: HANDLE) -> BOOL;
888-
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
889-
lpTargetFileName: LPCWSTR,
890-
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
891-
-> BOOL;
892892
pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
893893
lpNewFileName: LPCWSTR,
894894
dwFlags: DWORD)

src/libstd/sys/windows/fs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ pub fn symlink_inner(src: &Path, dst: &Path, dir: bool) -> io::Result<()> {
670670
Ok(())
671671
}
672672

673+
#[cfg(not(target_vendor = "uwp"))]
673674
pub fn link(src: &Path, dst: &Path) -> io::Result<()> {
674675
let src = to_u16s(src)?;
675676
let dst = to_u16s(dst)?;
@@ -679,6 +680,12 @@ pub fn link(src: &Path, dst: &Path) -> io::Result<()> {
679680
Ok(())
680681
}
681682

683+
#[cfg(target_vendor = "uwp")]
684+
pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> {
685+
return Err(io::Error::new(io::ErrorKind::Other,
686+
"hard link are not supported on UWP"));
687+
}
688+
682689
pub fn stat(path: &Path) -> io::Result<FileAttr> {
683690
let mut opts = OpenOptions::new();
684691
// No read or write permissions are necessary

0 commit comments

Comments
 (0)