diff options
| author | Ingvar Stepanyan <rreverser@google.com> | 2021-02-03 15:45:30 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-03 15:45:30 +0000 |
| commit | 1578f2e1e8736e4e68f720146247d402bee6c1bf (patch) | |
| tree | 0dd10f374de3a18f240e5c4751ce777e7c37ff76 | |
| parent | 5882cce54ea902c234421c19de0a26a2adcaf6cc (diff) | |
| download | rust-1578f2e1e8736e4e68f720146247d402bee6c1bf.tar.gz rust-1578f2e1e8736e4e68f720146247d402bee6c1bf.zip | |
Keep old symlink; expose new symlink_path
| -rw-r--r-- | library/std/src/sys/wasi/ext/fs.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/library/std/src/sys/wasi/ext/fs.rs b/library/std/src/sys/wasi/ext/fs.rs index 36530e4bb35..42adcd777dc 100644 --- a/library/std/src/sys/wasi/ext/fs.rs +++ b/library/std/src/sys/wasi/ext/fs.rs @@ -502,11 +502,21 @@ pub fn rename<P: AsRef<Path>, U: AsRef<Path>>( ) } +/// This corresponds to the `path_symlink` syscall. +pub fn symlink<P: AsRef<Path>, U: AsRef<Path>>( + old_path: P, + fd: &File, + new_path: U, +) -> io::Result<()> { + fd.as_inner() + .fd() + .symlink(osstr2str(old_path.as_ref().as_ref())?, osstr2str(new_path.as_ref().as_ref())?) +} + /// Create a symbolic link. /// -/// This is similar to [`std::os::unix::fs::symlink`] and -/// [`std::os::windows::fs::symlink_file`] and [`symlink_dir`](std::os::windows::fs::symlink_dir) -/// counterparts. -pub fn symlink<P: AsRef<Path>, U: AsRef<Path>>(old_path: P, new_path: U) -> io::Result<()> { +/// This is a convenience API similar to [`std::os::unix::fs::symlink`] and +/// [`std::os::windows::fs::symlink_file`] and [`symlink_dir`](std::os::windows::fs::symlink_dir). +pub fn symlink_path<P: AsRef<Path>, U: AsRef<Path>>(old_path: P, new_path: U) -> io::Result<()> { crate::sys::fs::symlink(old_path.as_ref(), new_path.as_ref()) } |
