switch to cap-fs-ext::MetadataExt
This commit is contained in:
@@ -21,13 +21,11 @@ getrandom = { version = "0.2.0", features = ["std"] }
|
||||
wiggle = { path = "../wiggle", default-features = false, version = "0.21.0" }
|
||||
tracing = "0.1.19"
|
||||
system-interface = "0.2"
|
||||
cap-std = "0.6"
|
||||
cap-std = "0.7"
|
||||
cap-fs-ext = "0.7"
|
||||
fs-set-times = "0.2.1"
|
||||
cfg-if = "1"
|
||||
|
||||
[build-dependencies]
|
||||
rustc_version = "0.2"
|
||||
|
||||
[badges]
|
||||
maintenance = { status = "actively-developed" }
|
||||
|
||||
|
||||
@@ -5,14 +5,4 @@ fn main() {
|
||||
let wasi = cwd.join("..").join("wasi-common").join("WASI");
|
||||
println!("cargo:wasi={}", wasi.display());
|
||||
println!("cargo:rustc-env=WASI_ROOT={}", wasi.display());
|
||||
|
||||
match rustc_version::version_meta()
|
||||
.expect("query rustc release channel")
|
||||
.channel
|
||||
{
|
||||
rustc_version::Channel::Nightly => {
|
||||
println!("cargo:rustc-cfg=nightly");
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,14 +177,16 @@ impl WasiFile for cap_std::fs::File {
|
||||
if meta.is_file() {
|
||||
Ok(Filetype::RegularFile)
|
||||
} else {
|
||||
Err(Error::Badf) // XXX idk what to do here
|
||||
todo!("get_filetype doesnt know how to handle case when not a file");
|
||||
}
|
||||
}
|
||||
fn get_fdflags(&self) -> Result<FdFlags, Error> {
|
||||
// XXX cap-std doesnt expose append, dsync, nonblock, rsync, sync
|
||||
todo!()
|
||||
todo!("get_fdflags is not implemented")
|
||||
}
|
||||
fn get_oflags(&self) -> Result<OFlags, Error> {
|
||||
#![allow(unreachable_code, unused_variables)]
|
||||
todo!("get_oflags implementation is incomplete");
|
||||
// XXX what if it was opened append, async, nonblock...
|
||||
let perms = self.metadata()?.permissions();
|
||||
if perms.readonly() {
|
||||
@@ -210,27 +212,12 @@ impl WasiFile for cap_std::fs::File {
|
||||
}
|
||||
fn get_filestat(&self) -> Result<Filestat, Error> {
|
||||
let meta = self.metadata()?;
|
||||
let (device_id, inode, nlink) = {
|
||||
cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
(meta.dev(), meta.ino(), meta.nlink())
|
||||
} else if #[cfg(all(windows, feature = "nightly"))] {
|
||||
use std::os::windows::fs::MetadataExt;
|
||||
( meta.volume_serial_number().unwrap_or(-1),
|
||||
meta.file_index().unwrap_or(-1),
|
||||
meta.number_of_links().unwrap_or(0),
|
||||
)
|
||||
} else {
|
||||
(-1, -1, 0)
|
||||
}
|
||||
}
|
||||
};
|
||||
use cap_fs_ext::MetadataExt;
|
||||
Ok(Filestat {
|
||||
device_id,
|
||||
inode,
|
||||
device_id: meta.dev(),
|
||||
inode: meta.ino(),
|
||||
filetype: self.get_filetype()?,
|
||||
nlink,
|
||||
nlink: meta.nlink(),
|
||||
size: meta.len(),
|
||||
atim: meta.accessed()?.into_std(),
|
||||
mtim: meta.modified()?.into_std(),
|
||||
|
||||
Reference in New Issue
Block a user