From 5a97036b6900ee208f90c52ceadcce606d497e93 Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Sat, 20 May 2017 15:40:53 -0400 Subject: Convert Intos to Froms. --- src/libstd/ffi/c_str.rs | 6 +++--- src/libstd/ffi/os_str.rs | 6 +++--- src/libstd/path.rs | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 1a91417ca0e..1586e0a4ddb 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -586,10 +586,10 @@ impl From> for CString { } #[stable(feature = "box_from_c_string", since = "1.18.0")] -impl Into> for CString { +impl From for Box { #[inline] - fn into(self) -> Box { - self.into_boxed_c_str() + fn from(s: CString) -> Box { + s.into_boxed_c_str() } } diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index f54d79c201f..3815f986681 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -543,9 +543,9 @@ impl From> for OsString { } #[stable(feature = "box_from_os_string", since = "1.18.0")] -impl Into> for OsString { - fn into(self) -> Box { - self.into_boxed_os_str() +impl From for Box { + fn from(s: OsString) -> Box { + s.into_boxed_os_str() } } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 42a54ed6d75..e9bf7b33b8e 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1349,9 +1349,9 @@ impl From> for PathBuf { } #[stable(feature = "box_from_path_buf", since = "1.18.0")] -impl Into> for PathBuf { - fn into(self) -> Box { - self.into_boxed_path() +impl From for Box { + fn from(p: PathBuf) -> Box { + p.into_boxed_path() } } -- cgit 1.4.1-3-g733a5 From 0d885efe16899c2dbad2918345c9ede7b83caa7f Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Tue, 13 Jun 2017 00:08:37 +0100 Subject: Update version numbers for From impls --- src/liballoc/string.rs | 2 +- src/libstd/ffi/c_str.rs | 2 +- src/libstd/ffi/os_str.rs | 2 +- src/libstd/path.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libstd') diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs index c1ef1c2f96c..02ecb65fa38 100644 --- a/src/liballoc/string.rs +++ b/src/liballoc/string.rs @@ -2008,7 +2008,7 @@ impl From> for String { } } -#[stable(feature = "box_from_str", since = "1.18.0")] +#[stable(feature = "box_from_str", since = "1.20.0")] impl From for Box { fn from(s: String) -> Box { s.into_boxed_str() diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 1586e0a4ddb..5f0b11a616e 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -585,7 +585,7 @@ impl From> for CString { } } -#[stable(feature = "box_from_c_string", since = "1.18.0")] +#[stable(feature = "box_from_c_string", since = "1.20.0")] impl From for Box { #[inline] fn from(s: CString) -> Box { diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 3815f986681..3232a51546e 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -542,7 +542,7 @@ impl From> for OsString { } } -#[stable(feature = "box_from_os_string", since = "1.18.0")] +#[stable(feature = "box_from_os_string", since = "1.20.0")] impl From for Box { fn from(s: OsString) -> Box { s.into_boxed_os_str() diff --git a/src/libstd/path.rs b/src/libstd/path.rs index e9bf7b33b8e..7a8c8935394 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1348,7 +1348,7 @@ impl From> for PathBuf { } } -#[stable(feature = "box_from_path_buf", since = "1.18.0")] +#[stable(feature = "box_from_path_buf", since = "1.20.0")] impl From for Box { fn from(p: PathBuf) -> Box { p.into_boxed_path() -- cgit 1.4.1-3-g733a5 From 8ee6bddf0b8b9b77ecd1e4b8105dc3fe161e6626 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 29 Jun 2017 17:22:36 -0700 Subject: redox: symlink and readlink --- src/libstd/sys/redox/fs.rs | 14 ++++++++++---- src/libstd/sys/redox/syscall/flag.rs | 2 ++ 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/redox/fs.rs b/src/libstd/sys/redox/fs.rs index 48d9cdcb2c9..9a16fc1bf66 100644 --- a/src/libstd/sys/redox/fs.rs +++ b/src/libstd/sys/redox/fs.rs @@ -420,12 +420,18 @@ fn remove_dir_all_recursive(path: &Path) -> io::Result<()> { } pub fn readlink(p: &Path) -> io::Result { - canonicalize(p) + let fd = cvt(syscall::open(p.to_str().unwrap(), syscall::O_SYMLINK | syscall::O_RDONLY))?; + let mut buf: [u8; 4096] = [0; 4096]; + let count = cvt(syscall::read(fd, &mut buf))?; + cvt(syscall::close(fd))?; + Ok(PathBuf::from(unsafe { String::from_utf8_unchecked(Vec::from(&buf[..count])) })) } -pub fn symlink(_src: &Path, _dst: &Path) -> io::Result<()> { - ::sys_common::util::dumb_print(format_args!("Symlink\n")); - unimplemented!(); +pub fn symlink(src: &Path, dst: &Path) -> io::Result<()> { + let fd = cvt(syscall::open(dst.to_str().unwrap(), syscall::O_SYMLINK | syscall::O_CREAT | syscall::O_WRONLY | 0o777))?; + cvt(syscall::write(fd, src.to_str().unwrap().as_bytes()))?; + cvt(syscall::close(fd))?; + Ok(()) } pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> { diff --git a/src/libstd/sys/redox/syscall/flag.rs b/src/libstd/sys/redox/syscall/flag.rs index 9f0d3e6f779..bd603cfe6ef 100644 --- a/src/libstd/sys/redox/syscall/flag.rs +++ b/src/libstd/sys/redox/syscall/flag.rs @@ -33,6 +33,7 @@ pub const MAP_WRITE_COMBINE: usize = 2; pub const MODE_TYPE: u16 = 0xF000; pub const MODE_DIR: u16 = 0x4000; pub const MODE_FILE: u16 = 0x8000; +pub const MODE_SYMLINK: u16 = 0xA000; pub const MODE_PERM: u16 = 0x0FFF; pub const MODE_SETUID: u16 = 0o4000; @@ -53,6 +54,7 @@ pub const O_TRUNC: usize = 0x0400_0000; pub const O_EXCL: usize = 0x0800_0000; pub const O_DIRECTORY: usize = 0x1000_0000; pub const O_STAT: usize = 0x2000_0000; +pub const O_SYMLINK: usize = 0x4000_0000; pub const O_ACCMODE: usize = O_RDONLY | O_WRONLY | O_RDWR; pub const SEEK_SET: usize = 0; -- cgit 1.4.1-3-g733a5 From 3456608aaed5db6ec3a520a295983e97c4f031fd Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Fri, 30 Jun 2017 13:37:05 -0700 Subject: Fix long line --- src/libstd/sys/redox/fs.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/libstd') diff --git a/src/libstd/sys/redox/fs.rs b/src/libstd/sys/redox/fs.rs index 9a16fc1bf66..c5a19e8debe 100644 --- a/src/libstd/sys/redox/fs.rs +++ b/src/libstd/sys/redox/fs.rs @@ -428,7 +428,8 @@ pub fn readlink(p: &Path) -> io::Result { } pub fn symlink(src: &Path, dst: &Path) -> io::Result<()> { - let fd = cvt(syscall::open(dst.to_str().unwrap(), syscall::O_SYMLINK | syscall::O_CREAT | syscall::O_WRONLY | 0o777))?; + let fd = cvt(syscall::open(dst.to_str().unwrap(), + syscall::O_SYMLINK | syscall::O_CREAT | syscall::O_WRONLY | 0o777))?; cvt(syscall::write(fd, src.to_str().unwrap().as_bytes()))?; cvt(syscall::close(fd))?; Ok(()) -- cgit 1.4.1-3-g733a5