add hard_link to dir

This commit is contained in:
Pat Hickey
2021-01-05 12:19:56 -08:00
parent 21cd55b0a7
commit 07a9584a08
3 changed files with 39 additions and 6 deletions

View File

@@ -27,6 +27,13 @@ pub trait WasiDir {
fn read_link(&self, path: &str) -> Result<PathBuf, Error>;
fn get_filestat(&self) -> Result<Filestat, Error>;
fn rename(&self, path: &str, dest_dir: &dyn WasiDir, dest_path: &str) -> Result<(), Error>;
fn hard_link(
&self,
path: &str,
symlink_follow: bool,
target_dir: &dyn WasiDir,
target_path: &str,
) -> Result<(), Error>;
}
pub(crate) struct DirEntry {
@@ -363,4 +370,18 @@ impl WasiDir for cap_std::fs::Dir {
self.rename(Path::new(src_path), dest_dir, Path::new(dest_path))?;
Ok(())
}
fn hard_link(
&self,
src_path: &str,
symlink_follow: bool,
target_dir: &dyn WasiDir,
target_path: &str,
) -> Result<(), Error> {
let target_dir = target_dir
.as_any()
.downcast_ref::<Self>()
.ok_or(Error::NotCapable)?;
self.hard_link(Path::new(src_path), target_dir, Path::new(target_path))?;
Ok(())
}
}