From 771c0f5356a04bce58eabbd9f2b0366b2f3694fb Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Mon, 22 Feb 2021 17:02:34 +0000 Subject: [PATCH] Fix WASI symlink implementation (#52) As described in #51, current implementation is incorrect and won't work and, as described in https://github.com/rust-lang/rust/issues/68574, there was no correct way to use that API. I went ahead and added a new API for symlinks in https://github.com/rust-lang/rust/pull/81542, and now that it's landed, it can be used to correctly create symlinks. Fixes #51. --- src/dir.rs | 3 +-- src/file.rs | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/dir.rs b/src/dir.rs index 2490e62..41592d4 100644 --- a/src/dir.rs +++ b/src/dir.rs @@ -525,8 +525,7 @@ impl PathOps for PathDir { #[cfg(target_os = "wasi")] fn symlink_dir, Q: AsRef>(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)] diff --git a/src/file.rs b/src/file.rs index 335d11a..e87e4db 100644 --- a/src/file.rs +++ b/src/file.rs @@ -572,8 +572,7 @@ impl PathOps for PathFile { #[cfg(target_os = "wasi")] fn symlink_file, Q: AsRef>(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)]