make get_filestat work
up to 16 tests passing!
This commit is contained in:
@@ -87,14 +87,14 @@ impl std::ops::BitOr for OFlags {
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Filestat {
|
pub struct Filestat {
|
||||||
device_id: u64,
|
pub device_id: u64,
|
||||||
inode: u64,
|
pub inode: u64,
|
||||||
filetype: Filetype,
|
pub filetype: Filetype,
|
||||||
nlink: u64,
|
pub nlink: u64,
|
||||||
size: u64,
|
pub size: u64,
|
||||||
atim: std::time::SystemTime,
|
pub atim: std::time::SystemTime,
|
||||||
mtim: std::time::SystemTime,
|
pub mtim: std::time::SystemTime,
|
||||||
ctim: std::time::SystemTime,
|
pub ctim: std::time::SystemTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct FileEntry {
|
pub(crate) struct FileEntry {
|
||||||
@@ -232,7 +232,7 @@ impl WasiFile for cap_std::fs::File {
|
|||||||
fn get_oflags(&self) -> Result<OFlags, Error> {
|
fn get_oflags(&self) -> Result<OFlags, Error> {
|
||||||
todo!("get_oflags is not implemented");
|
todo!("get_oflags is not implemented");
|
||||||
}
|
}
|
||||||
fn set_oflags(&self, flags: OFlags) -> Result<(), Error> {
|
fn set_oflags(&self, _flags: OFlags) -> Result<(), Error> {
|
||||||
todo!("set_oflags is not implemented");
|
todo!("set_oflags is not implemented");
|
||||||
}
|
}
|
||||||
fn get_filestat(&self) -> Result<Filestat, Error> {
|
fn get_filestat(&self) -> Result<Filestat, Error> {
|
||||||
@@ -244,9 +244,19 @@ impl WasiFile for cap_std::fs::File {
|
|||||||
filetype: self.get_filetype()?,
|
filetype: self.get_filetype()?,
|
||||||
nlink: meta.nlink(),
|
nlink: meta.nlink(),
|
||||||
size: meta.len(),
|
size: meta.len(),
|
||||||
atim: meta.accessed()?.into_std(),
|
// XXX handle these features not being available better:
|
||||||
mtim: meta.modified()?.into_std(),
|
atim: meta
|
||||||
ctim: meta.created()?.into_std(),
|
.accessed()
|
||||||
|
.map(|t| t.into_std())
|
||||||
|
.unwrap_or_else(|_| std::time::SystemTime::UNIX_EPOCH),
|
||||||
|
mtim: meta
|
||||||
|
.modified()
|
||||||
|
.map(|t| t.into_std())
|
||||||
|
.unwrap_or_else(|_| std::time::SystemTime::UNIX_EPOCH),
|
||||||
|
ctim: meta
|
||||||
|
.created()
|
||||||
|
.map(|t| t.into_std())
|
||||||
|
.unwrap_or_else(|_| std::time::SystemTime::UNIX_EPOCH),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
fn set_filestat_size(&self, size: u64) -> Result<(), Error> {
|
fn set_filestat_size(&self, size: u64) -> Result<(), Error> {
|
||||||
|
|||||||
@@ -1024,6 +1024,27 @@ impl From<&OFlags> for types::Oflags {
|
|||||||
}
|
}
|
||||||
impl From<Filestat> for types::Filestat {
|
impl From<Filestat> for types::Filestat {
|
||||||
fn from(stat: Filestat) -> types::Filestat {
|
fn from(stat: Filestat) -> types::Filestat {
|
||||||
todo!()
|
types::Filestat {
|
||||||
|
dev: stat.device_id,
|
||||||
|
ino: stat.inode,
|
||||||
|
filetype: types::Filetype::from(&stat.filetype),
|
||||||
|
nlink: stat.nlink,
|
||||||
|
size: stat.size,
|
||||||
|
atim: stat
|
||||||
|
.atim
|
||||||
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_nanos() as u64,
|
||||||
|
mtim: stat
|
||||||
|
.mtim
|
||||||
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_nanos() as u64,
|
||||||
|
ctim: stat
|
||||||
|
.ctim
|
||||||
|
.duration_since(std::time::UNIX_EPOCH)
|
||||||
|
.unwrap()
|
||||||
|
.as_nanos() as u64,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user