feat(wasi) add push_file and push_dir methods to WasiCtx (#5027)
These are useful when we don't want to collide with an existing file descriptor.
This commit is contained in:
@@ -43,6 +43,10 @@ impl WasiCtx {
|
|||||||
.insert_at(fd, Box::new(FileEntry::new(caps, file)));
|
.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(
|
pub fn insert_dir(
|
||||||
&mut self,
|
&mut self,
|
||||||
fd: u32,
|
fd: u32,
|
||||||
@@ -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 {
|
pub fn table(&mut self) -> &mut Table {
|
||||||
&mut self.table
|
&mut self.table
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user