Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions crates/wasi-common/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,22 @@ impl WasiCtxBuilder {
self
}

/// Add a preopened handle.
///
/// This is the most generic function for adding a directory, but also the less easy to use.
pub fn preopened_handle<P: AsRef<Path>, T: 'static + Handle>(
&mut self,
dir: T,
guest_path: P,
) -> &mut Self {
let preopen = PendingPreopen::new(move || Ok(Box::new(dir)));
self.preopens
.as_mut()
.unwrap()
.push((guest_path.as_ref().to_owned(), preopen));
self
}

/// Build a `WasiCtx`, consuming this `WasiCtxBuilder`.
///
/// If any of the arguments or environment variables in this builder cannot be converted into
Expand Down