Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions cap-primitives/src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,6 @@ pub trait FileExt {
/// Create a directory.
fn create_directory<P: AsRef<std::path::Path>>(&self, dir: P) -> io::Result<()>;

/// Read the contents of a symbolic link.
fn read_link<P: AsRef<std::path::Path>>(&self, path: P) -> io::Result<std::path::PathBuf>;

/// Return the attributes of a file or directory.
fn metadata_at<P: AsRef<std::path::Path>>(
&self,
lookup_flags: u32,
path: P,
) -> io::Result<std::fs::Metadata>;

/// Unlink a file.
fn remove_file<P: AsRef<std::path::Path>>(&self, path: P) -> io::Result<()>;

Expand Down
28 changes: 0 additions & 28 deletions cap-primitives/src/fs/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,14 +250,6 @@ pub trait MetadataExt {
fn ino(&self) -> u64;
/// Returns the number of hard links pointing to this file.
fn nlink(&self) -> u64;
/// Returns the total size of this file in bytes.
fn size(&self) -> u64;
/// Returns the last access time of the file, in seconds since Unix Epoch.
fn atim(&self) -> u64;
/// Returns the last modification time of the file, in seconds since Unix Epoch.
fn mtim(&self) -> u64;
/// Returns the last status change time of the file, in seconds since Unix Epoch.
fn ctim(&self) -> u64;
}

/// Windows-specific extensions to [`Metadata`].
Expand Down Expand Up @@ -385,26 +377,6 @@ impl MetadataExt for Metadata {
fn nlink(&self) -> u64 {
crate::fs::MetadataExt::nlink(&self.ext)
}

#[inline]
fn size(&self) -> u64 {
crate::fs::MetadataExt::size(&self.ext)
}

#[inline]
fn atim(&self) -> u64 {
crate::fs::MetadataExt::atim(&self.ext)
}

#[inline]
fn mtim(&self) -> u64 {
crate::fs::MetadataExt::mtim(&self.ext)
}

#[inline]
fn ctim(&self) -> u64 {
crate::fs::MetadataExt::ctim(&self.ext)
}
}

#[cfg(target_os = "vxworks")]
Expand Down
3 changes: 0 additions & 3 deletions cap-primitives/src/rustix/fs/dir_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,9 @@ pub(crate) fn open_ambient_dir_impl(
let mut options = fs::OpenOptions::new();
options.read(true);

#[cfg(not(target_os = "wasi"))]
// This is for `std::fs`, so we don't have `dir_required`, so set
// `O_DIRECTORY` manually.
options.custom_flags((OFlags::DIRECTORY | target_o_path()).bits() as i32);
#[cfg(target_os = "wasi")]
options.directory(true);

options.open(path)
}
Expand Down
46 changes: 4 additions & 42 deletions cap-primitives/src/rustix/fs/metadata_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub(crate) struct ImplMetadataExt {
gid: u32,
#[cfg(not(target_os = "wasi"))]
rdev: u64,
#[cfg(not(target_os = "wasi"))]
size: u64,
#[cfg(not(target_os = "wasi"))]
atime: i64,
Expand All @@ -37,12 +38,6 @@ pub(crate) struct ImplMetadataExt {
blksize: u64,
#[cfg(not(target_os = "wasi"))]
blocks: u64,
#[cfg(target_os = "wasi")]
atim: u64,
#[cfg(target_os = "wasi")]
mtim: u64,
#[cfg(target_os = "wasi")]
ctim: u64,
}

impl ImplMetadataExt {
Expand Down Expand Up @@ -72,6 +67,7 @@ impl ImplMetadataExt {
gid: std.gid(),
#[cfg(not(target_os = "wasi"))]
rdev: std.rdev(),
#[cfg(not(target_os = "wasi"))]
size: std.size(),
#[cfg(not(target_os = "wasi"))]
atime: std.atime(),
Expand All @@ -89,12 +85,6 @@ impl ImplMetadataExt {
blksize: std.blksize(),
#[cfg(not(target_os = "wasi"))]
blocks: std.blocks(),
#[cfg(target_os = "wasi")]
atim: std.atim(),
#[cfg(target_os = "wasi")]
mtim: std.mtim(),
#[cfg(target_os = "wasi")]
ctim: std.ctim(),
}
}

Expand Down Expand Up @@ -179,6 +169,7 @@ impl ImplMetadataExt {
gid: stat.st_gid,
#[cfg(not(target_os = "wasi"))]
rdev: u64::try_from(stat.st_rdev).unwrap(),
#[cfg(not(target_os = "wasi"))]
size: u64::try_from(stat.st_size).unwrap(),
#[cfg(not(target_os = "wasi"))]
atime: i64::try_from(stat.st_atime).unwrap(),
Expand All @@ -196,21 +187,6 @@ impl ImplMetadataExt {
blksize: u64::try_from(stat.st_blksize).unwrap(),
#[cfg(not(target_os = "wasi"))]
blocks: u64::try_from(stat.st_blocks).unwrap(),
#[cfg(target_os = "wasi")]
atim: u64::try_from(
stat.st_atim.tv_sec as u64 * 1000000000 + stat.st_atim.tv_nsec as u64,
)
.unwrap(),
#[cfg(target_os = "wasi")]
mtim: u64::try_from(
stat.st_mtim.tv_sec as u64 * 1000000000 + stat.st_mtim.tv_nsec as u64,
)
.unwrap(),
#[cfg(target_os = "wasi")]
ctim: u64::try_from(
stat.st_ctim.tv_sec as u64 * 1000000000 + stat.st_ctim.tv_nsec as u64,
)
.unwrap(),
},
}
}
Expand Down Expand Up @@ -319,6 +295,7 @@ impl crate::fs::MetadataExt for ImplMetadataExt {
self.rdev
}

#[cfg(not(target_os = "wasi"))]
#[inline]
fn size(&self) -> u64 {
self.size
Expand Down Expand Up @@ -371,21 +348,6 @@ impl crate::fs::MetadataExt for ImplMetadataExt {
fn blocks(&self) -> u64 {
self.blocks
}

#[cfg(target_os = "wasi")]
fn atim(&self) -> u64 {
self.atim
}

#[cfg(target_os = "wasi")]
fn mtim(&self) -> u64 {
self.mtim
}

#[cfg(target_os = "wasi")]
fn ctim(&self) -> u64 {
self.ctim
}
}

/// It should be possible to represent times before the Epoch.
Expand Down
17 changes: 0 additions & 17 deletions cap-std/src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,23 +552,6 @@ impl crate::fs::FileExt for File {
std::os::wasi::fs::FileExt::create_directory(&self.std, dir)
}

#[inline]
fn read_link<P: AsRef<Path>>(
&self,
path: P,
) -> std::result::Result<std::path::PathBuf, io::Error> {
std::os::wasi::fs::FileExt::read_link(&self.std, path)
}

#[inline]
fn metadata_at<P: AsRef<Path>>(
&self,
lookup_flags: u32,
path: P,
) -> std::result::Result<std::fs::Metadata, io::Error> {
std::os::wasi::fs::FileExt::metadata_at(&self.std, lookup_flags, path)
}

#[inline]
fn remove_file<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), io::Error> {
std::os::wasi::fs::FileExt::remove_file(&self.std, path)
Expand Down
19 changes: 0 additions & 19 deletions cap-std/src/fs_utf8/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,25 +551,6 @@ impl crate::fs::FileExt for File {
self.cap_std.create_directory(path)
}

#[inline]
fn read_link<P: AsRef<Path>>(
&self,
path: P,
) -> std::result::Result<std::path::PathBuf, io::Error> {
let path = path.as_ref();
self.cap_std.read_link(path)
}

#[inline]
fn metadata_at<P: AsRef<Path>>(
&self,
lookup_flags: u32,
path: P,
) -> std::result::Result<std::fs::Metadata, io::Error> {
let path = path.as_ref();
self.cap_std.metadata_at(lookup_flags, path)
}

#[inline]
fn remove_file<P: AsRef<Path>>(&self, path: P) -> std::result::Result<(), io::Error> {
let path = path.as_ref();
Expand Down