Skip to content

Commit

Permalink
std: win: Don't expose link() on UWP
Browse files Browse the repository at this point in the history
Or rather expose it, but always return an error
  • Loading branch information
chouquette committed Jul 25, 2019
1 parent a713a03 commit ef26728
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/libstd/sys/windows/c.rs
Expand Up @@ -667,6 +667,10 @@ if #[cfg(not(target_vendor = "uwp"))] {
pub fn SetHandleInformation(hObject: HANDLE,
dwMask: DWORD,
dwFlags: DWORD) -> BOOL;
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
lpTargetFileName: LPCWSTR,
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
-> BOOL;
}
}
}
Expand Down Expand Up @@ -883,10 +887,6 @@ extern "system" {
lpOverlapped: LPOVERLAPPED)
-> BOOL;
pub fn CloseHandle(hObject: HANDLE) -> BOOL;
pub fn CreateHardLinkW(lpSymlinkFileName: LPCWSTR,
lpTargetFileName: LPCWSTR,
lpSecurityAttributes: LPSECURITY_ATTRIBUTES)
-> BOOL;
pub fn MoveFileExW(lpExistingFileName: LPCWSTR,
lpNewFileName: LPCWSTR,
dwFlags: DWORD)
Expand Down
7 changes: 7 additions & 0 deletions src/libstd/sys/windows/fs.rs
Expand Up @@ -670,6 +670,7 @@ pub fn symlink_inner(src: &Path, dst: &Path, dir: bool) -> io::Result<()> {
Ok(())
}

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

#[cfg(target_vendor = "uwp")]
pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> {
return Err(io::Error::new(io::ErrorKind::Other,
"hard link are not supported on UWP"));
}

pub fn stat(path: &Path) -> io::Result<FileAttr> {
let mut opts = OpenOptions::new();
// No read or write permissions are necessary
Expand Down

0 comments on commit ef26728

Please sign in to comment.