Hello, using a WasiCtx in which my wasi runs, I wonder how it could parse a directory?
I saw that wasi_filesystem is being integrated to wasmtime, but I saw a preopened_dir method. But I didn’t see any documentation on it.
There is two arguments: fd, and dir
I must get the file descriptor of the host folder? Ane how can I generate a Dir object?
You can use push_preopened_dir on WasiCtx (not WasiCtxBuilder) to add a preopened dir to the WasiCtx. This method only needs a dir and path, no fd. WasiDir is implemented by the wasmtime_wasi::sync::dir::Dir
type which has the from_cap_std function. This function takes a wasmtime_wasi::sync::Dir
as argument, which you can construct using the from_ambient_dir
function. The AmbientAuthority
argument can be constructed using wasmtime_wasi::sync::ambient_authority()
.
Oh wow, I wouldn't have find this myself, thanks a lot xD I'm gonna try this right now
Well I struggled to make this work, because there is wasmtime_wasi::sync::Dir
and wasmtime_wasi::sync::dir::Dir
.. so I struggled for an hour lol
bachrc has marked this topic as resolved.
Last updated: Nov 22 2024 at 16:03 UTC