dir: add set times

This commit is contained in:
Pat Hickey
2021-01-05 14:24:02 -08:00
parent 16eff680e2
commit ce13cd9e77
3 changed files with 63 additions and 25 deletions

View File

@@ -1,5 +1,6 @@
use crate::error::Error;
use crate::file::{FdFlags, FileCaps, FileType, Filestat, OFlags, WasiFile};
use cap_fs_ext::SystemTimeSpec;
use std::any::Any;
use std::convert::TryInto;
use std::ops::Deref;
@@ -35,6 +36,12 @@ pub trait WasiDir {
target_dir: &dyn WasiDir,
target_path: &str,
) -> Result<(), Error>;
fn set_times(
&self,
path: &str,
atime: Option<SystemTimeSpec>,
mtime: Option<SystemTimeSpec>,
) -> Result<(), Error>;
}
pub(crate) struct DirEntry {
@@ -399,4 +406,13 @@ impl WasiDir for cap_std::fs::Dir {
self.hard_link(Path::new(src_path), target_dir, Path::new(target_path))?;
Ok(())
}
fn set_times(
&self,
path: &str,
atime: Option<SystemTimeSpec>,
mtime: Option<SystemTimeSpec>,
) -> Result<(), Error> {
cap_fs_ext::DirExt::set_times(self, Path::new(path), atime, mtime)?;
Ok(())
}
}