diff options
| author | Jeremy Soller <jackpot51@gmail.com> | 2016-11-28 20:21:19 -0700 |
|---|---|---|
| committer | Jeremy Soller <jackpot51@gmail.com> | 2016-11-28 20:21:19 -0700 |
| commit | 6378c77716aa66a12af0fb41abf3dc000b81c2c7 (patch) | |
| tree | de5bb39b3fb09a05b16da6326c4618c72c2a9ddb | |
| parent | 1d0bba8224686d054378bcc4e853798d56fdfecf (diff) | |
| download | rust-6378c77716aa66a12af0fb41abf3dc000b81c2c7.tar.gz rust-6378c77716aa66a12af0fb41abf3dc000b81c2c7.zip | |
Remove file path from std::fs::File
| -rw-r--r-- | src/libstd/fs.rs | 10 | ||||
| -rw-r--r-- | src/libstd/sys/redox/fs.rs | 6 |
2 files changed, 2 insertions, 14 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 0cb9a49ad67..e91e808c548 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -383,16 +383,6 @@ impl File { pub fn set_permissions(&self, perm: Permissions) -> io::Result<()> { self.inner.set_permissions(perm.0) } - - /// Get the path that this file points to. - /// - /// This function is only implemented on Redox, but could be - /// implemented on other operating systems using readlink - #[cfg(target_os = "redox")] - #[unstable(feature = "file_path", issue="0")] - pub fn path(&self) -> io::Result<PathBuf> { - self.inner.path() - } } impl AsInner<fs_imp::File> for File { diff --git a/src/libstd/sys/redox/fs.rs b/src/libstd/sys/redox/fs.rs index 80aec2e978d..9d5d2f5d921 100644 --- a/src/libstd/sys/redox/fs.rs +++ b/src/libstd/sys/redox/fs.rs @@ -319,10 +319,8 @@ impl File { pub fn path(&self) -> io::Result<PathBuf> { let mut buf: [u8; 4096] = [0; 4096]; - match syscall::fpath(*self.fd().as_inner() as usize, &mut buf) { - Ok(count) => Ok(PathBuf::from(unsafe { String::from_utf8_unchecked(Vec::from(&buf[0..count])) })), - Err(err) => Err(Error::from_raw_os_error(err.errno)), - } + let count = cvt(syscall::fpath(*self.fd().as_inner() as usize, &mut buf))?; + Ok(PathBuf::from(unsafe { String::from_utf8_unchecked(Vec::from(&buf[..count])) })) } pub fn fd(&self) -> &FileDesc { &self.0 } |
