Skip to content

Commit

Permalink
Fix WASI symlink implementation
Browse files Browse the repository at this point in the history
As described in vitiral#51, current implementation is incorrect and won't work and, as described in rust-lang/rust#68574, there was no correct way to use that API.

I went ahead and added a new API for symlinks in rust-lang/rust#81542, and now that it's landed, it can be used to correctly create symlinks.

Fixes vitiral#51.
  • Loading branch information
RReverser committed Feb 19, 2021
1 parent 9358459 commit 3dfaba2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,7 @@ impl PathOps for PathDir {

#[cfg(target_os = "wasi")]
fn symlink_dir<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
let file = std::fs::File::open(&src)?;
std::os::wasi::fs::symlink(src, &file, dst)
std::os::wasi::fs::symlink_path(src, dst)
}

#[cfg(unix)]
Expand Down
3 changes: 1 addition & 2 deletions src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,7 @@ impl PathOps for PathFile {

#[cfg(target_os = "wasi")]
fn symlink_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()> {
let file = std::fs::File::open(&src)?;
std::os::wasi::fs::symlink(src, &file, dst)
std::os::wasi::fs::symlink_path(src, dst)
}

#[cfg(unix)]
Expand Down

0 comments on commit 3dfaba2

Please sign in to comment.