Skip to content

Commit 771c0f5

Browse files
authored
Fix WASI symlink implementation (#52)
As described in #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 #51.
1 parent 9358459 commit 771c0f5

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/dir.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,7 @@ impl PathOps for PathDir {
525525

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

532531
#[cfg(unix)]

src/file.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -572,8 +572,7 @@ impl PathOps for PathFile {
572572

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

579578
#[cfg(unix)]

0 commit comments

Comments
 (0)