Skip to content

Commit ef26728

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

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
@@ -667,6 +667,10 @@ if #[cfg(not(target_vendor = "uwp"))] {
667667
pub fn SetHandleInformation(hObject: HANDLE,
668668
dwMask: DWORD,
669669
dwFlags: DWORD) -> BOOL;
670+
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
671+
lpTargetFileName: LPCWSTR,
672+
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
673+
-> BOOL;
670674
}
671675
}
672676
}
@@ -883,10 +887,6 @@ extern "system" {
883887
lpOverlapped: LPOVERLAPPED)
884888
-> BOOL;
885889
pub fn CloseHandle(hObject: HANDLE) -> BOOL;
886-
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
887-
lpTargetFileName: LPCWSTR,
888-
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
889-
-> BOOL;
890890
pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
891891
lpNewFileName: LPCWSTR,
892892
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)