diff options
| author | Alan Williams <mralert@gmail.com> | 2014-05-03 14:27:36 -0700 |
|---|---|---|
| committer | Alan Williams <mralert@gmail.com> | 2014-05-04 02:57:54 -0700 |
| commit | 073d7ffc2745386f42048847ec7209e47cbdab8f (patch) | |
| tree | 92fccddce6bc9f670929d825418411439e063f9f /src/libnative | |
| parent | 1f25c8b78d1192aea69ee9779f512eb9ee78e575 (diff) | |
| download | rust-073d7ffc2745386f42048847ec7209e47cbdab8f.tar.gz rust-073d7ffc2745386f42048847ec7209e47cbdab8f.zip | |
Implement fallbacks for functions unavailable in older versions of Windows
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/file_win32.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs index 6a6fb31d3e3..ea105b267c1 100644 --- a/src/libnative/io/file_win32.rs +++ b/src/libnative/io/file_win32.rs @@ -408,6 +408,7 @@ pub fn chown(_p: &CString, _uid: int, _gid: int) -> IoResult<()> { pub fn readlink(p: &CString) -> IoResult<Path> { // FIXME: I have a feeling that this reads intermediate symlinks as well. + use std::os::win32::compat::kernel32::GetFinalPathNameByHandleW; let handle = unsafe { as_utf16_p(p.as_str().unwrap(), |p| { libc::CreateFileW(p, @@ -425,10 +426,10 @@ pub fn readlink(p: &CString) -> IoResult<Path> { // Specify (sz - 1) because the documentation states that it's the size // without the null pointer let ret = fill_utf16_buf_and_decode(|buf, sz| unsafe { - libc::GetFinalPathNameByHandleW(handle, - buf as *u16, - sz - 1, - libc::VOLUME_NAME_DOS) + GetFinalPathNameByHandleW(handle, + buf as *u16, + sz - 1, + libc::VOLUME_NAME_DOS) }); let ret = match ret { Some(ref s) if s.starts_with(r"\\?\") => Ok(Path::new(s.slice_from(4))), @@ -440,9 +441,10 @@ pub fn readlink(p: &CString) -> IoResult<Path> { } pub fn symlink(src: &CString, dst: &CString) -> IoResult<()> { + use std::os::win32::compat::kernel32::CreateSymbolicLinkW; super::mkerr_winbool(as_utf16_p(src.as_str().unwrap(), |src| { as_utf16_p(dst.as_str().unwrap(), |dst| { - unsafe { libc::CreateSymbolicLinkW(dst, src, 0) } + unsafe { CreateSymbolicLinkW(dst, src, 0) } }) as libc::BOOL })) } |
