Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(wasi) add push_file and push_dir methods to WasiCtx #5027

Merged
merged 1 commit into from
Oct 7, 2022
Merged
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
15 changes: 15 additions & 0 deletions crates/wasi-common/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ impl WasiCtx {
.insert_at(fd, Box::new(FileEntry::new(caps, file)));
}

pub fn push_file(&mut self, file: Box<dyn WasiFile>, caps: FileCaps) -> Result<u32, Error> {
self.table().push(Box::new(FileEntry::new(caps, file)))
}

pub fn insert_dir(
&mut self,
fd: u32,
Expand All @@ -57,6 +61,17 @@ impl WasiCtx {
);
}

pub fn push_dir(
&mut self,
dir: Box<dyn WasiDir>,
caps: DirCaps,
file_caps: FileCaps,
path: PathBuf,
) -> Result<u32, Error> {
self.table()
.push(Box::new(DirEntry::new(caps, file_caps, Some(path), dir)))
}

pub fn table(&mut self) -> &mut Table {
&mut self.table
}
Expand Down