diff --git a/cap-async-std/src/fs/mod.rs b/cap-async-std/src/fs/mod.rs index 1b693128..357bf8cd 100644 --- a/cap-async-std/src/fs/mod.rs +++ b/cap-async-std/src/fs/mod.rs @@ -40,6 +40,7 @@ pub use cap_primitives::fs::{DirBuilder, FileType, Metadata, OpenOptions, Permis // Re-export conditional types from `cap_primitives`. #[cfg(any(unix, target_os = "vxworks", all(windows, windows_file_type_ext)))] pub use cap_primitives::fs::FileTypeExt; +pub use cap_primitives::fs::{PermissionsExt, MetadataExt}; // Re-export things from `async_std` that we can use as-is. #[cfg(target_os = "wasi")] diff --git a/cap-async-std/src/fs_utf8/mod.rs b/cap-async-std/src/fs_utf8/mod.rs index 7c3c4a6e..5d539b5a 100644 --- a/cap-async-std/src/fs_utf8/mod.rs +++ b/cap-async-std/src/fs_utf8/mod.rs @@ -25,6 +25,7 @@ pub use crate::fs::{DirBuilder, FileType, Metadata, OpenOptions, Permissions}; // Re-export conditional types from `cap_primitives`. #[cfg(any(unix, target_os = "vxworks", all(windows, windows_file_type_ext)))] pub use cap_primitives::fs::FileTypeExt; +pub use cap_primitives::fs::{PermissionsExt, MetadataExt}; // Re-export `camino` to make it easy for users to depend on the same // version we do, because we use its types in our public API. diff --git a/cap-std/src/fs/mod.rs b/cap-std/src/fs/mod.rs index 94883112..6dcc8ff0 100644 --- a/cap-std/src/fs/mod.rs +++ b/cap-std/src/fs/mod.rs @@ -38,3 +38,4 @@ pub use cap_primitives::fs::{DirBuilder, FileType, Metadata, OpenOptions, Permis // Re-export conditional types from `cap_primitives`. #[cfg(any(unix, target_os = "vxworks", all(windows, windows_file_type_ext)))] pub use cap_primitives::fs::FileTypeExt; +pub use cap_primitives::fs::{MetadataExt, PermissionsExt}; diff --git a/cap-std/src/fs_utf8/mod.rs b/cap-std/src/fs_utf8/mod.rs index c64220a6..e15b634e 100644 --- a/cap-std/src/fs_utf8/mod.rs +++ b/cap-std/src/fs_utf8/mod.rs @@ -27,6 +27,7 @@ pub use crate::fs::{DirBuilder, FileType, Metadata, OpenOptions, Permissions}; // Re-export conditional types from `cap_primitives`. #[cfg(any(unix, target_os = "vxworks", all(windows, windows_file_type_ext)))] pub use cap_primitives::fs::FileTypeExt; +pub use cap_primitives::fs::{MetadataExt, PermissionsExt}; // Re-export `camino` to make it easy for users to depend on the same // version we do, because we use its types in our public API. diff --git a/cap-tempfile/src/tempfile.rs b/cap-tempfile/src/tempfile.rs index 88da2247..a8d02be4 100644 --- a/cap-tempfile/src/tempfile.rs +++ b/cap-tempfile/src/tempfile.rs @@ -265,6 +265,7 @@ mod test { // Test that we created with the right permissions #[cfg(any(target_os = "android", target_os = "linux"))] { + use cap_std::fs_utf8::MetadataExt; use rustix::fs::{MetadataExt, Mode}; let umask = get_process_umask()?; let metadata = tf.as_file().metadata().unwrap(); diff --git a/tests/fs.rs b/tests/fs.rs index 483ef0c9..e14b4f41 100644 --- a/tests/fs.rs +++ b/tests/fs.rs @@ -334,7 +334,7 @@ fn file_test_io_read_write_at() { #[cfg(unix)] #[cfg_attr(any(target_os = "macos", target_os = "ios"), ignore)] fn set_get_unix_permissions() { - use std::os::unix::fs::PermissionsExt; + use cap_std::fs::PermissionsExt; let tmpdir = tmpdir(); let filename = "set_get_unix_permissions"; diff --git a/tests/fs_additional.rs b/tests/fs_additional.rs index 06cefa80..65dd0b6d 100644 --- a/tests/fs_additional.rs +++ b/tests/fs_additional.rs @@ -967,7 +967,10 @@ fn check_metadata(std: &std::fs::Metadata, cap: &cap_std::fs::Metadata) { #[cfg(unix)] { use std::os::unix::fs::PermissionsExt; - assert_eq!(std.permissions().mode(), cap.permissions().mode()); + assert_eq!( + std.permissions().mode(), + cap_std::fs::PermissionsExt::mode(&cap.permissions()) + ); } // If the standard library supports file modified/accessed/created times, @@ -1022,28 +1025,28 @@ fn check_metadata(std: &std::fs::Metadata, cap: &cap_std::fs::Metadata) { #[cfg(unix)] { use std::os::unix::fs::MetadataExt; - assert_eq!(std.dev(), cap.dev()); - assert_eq!(std.ino(), cap.ino()); - assert_eq!(std.mode(), cap.mode()); - assert_eq!(std.nlink(), cap.nlink()); - assert_eq!(std.uid(), cap.uid()); - assert_eq!(std.gid(), cap.gid()); - assert_eq!(std.rdev(), cap.rdev()); - assert_eq!(std.size(), cap.size()); + assert_eq!(std.dev(), cap_std::fs::MetadataExt::dev(cap)); + assert_eq!(std.ino(), cap_std::fs::MetadataExt::ino(cap)); + assert_eq!(std.mode(), cap_std::fs::MetadataExt::mode(cap)); + assert_eq!(std.nlink(), cap_std::fs::MetadataExt::nlink(cap)); + assert_eq!(std.uid(), cap_std::fs::MetadataExt::uid(cap)); + assert_eq!(std.gid(), cap_std::fs::MetadataExt::gid(cap)); + assert_eq!(std.rdev(), cap_std::fs::MetadataExt::rdev(cap)); + assert_eq!(std.size(), cap_std::fs::MetadataExt::size(cap)); assert!( ((std.atime() - i64::from(ACCESS_TOLERANCE_SEC)) ..(std.atime() + i64::from(ACCESS_TOLERANCE_SEC))) - .contains(&cap.atime()), + .contains(&cap_std::fs::MetadataExt::atime(cap)), "std atime {}, cap atime {}", std.atime(), - cap.atime() + cap_std::fs::MetadataExt::atime(cap) ); - assert!((0..1_000_000_000).contains(&cap.atime_nsec())); - assert_eq!(std.mtime(), cap.mtime()); - assert_eq!(std.mtime_nsec(), cap.mtime_nsec()); - assert_eq!(std.ctime(), cap.ctime()); - assert_eq!(std.ctime_nsec(), cap.ctime_nsec()); - assert_eq!(std.blksize(), cap.blksize()); - assert_eq!(std.blocks(), cap.blocks()); + assert!((0..1_000_000_000).contains(&cap_std::fs::MetadataExt::atime_nsec(cap))); + assert_eq!(std.mtime(), cap_std::fs::MetadataExt::mtime(cap)); + assert_eq!(std.mtime_nsec(), cap_std::fs::MetadataExt::mtime_nsec(cap)); + assert_eq!(std.ctime(), cap_std::fs::MetadataExt::ctime(cap)); + assert_eq!(std.ctime_nsec(), cap_std::fs::MetadataExt::ctime_nsec(cap)); + assert_eq!(std.blksize(), cap_std::fs::MetadataExt::blksize(cap)); + assert_eq!(std.blocks(), cap_std::fs::MetadataExt::blocks(cap)); } } diff --git a/tests/fs_utf8.rs b/tests/fs_utf8.rs index 8d88e7c0..3af9eb4f 100644 --- a/tests/fs_utf8.rs +++ b/tests/fs_utf8.rs @@ -335,7 +335,7 @@ fn file_test_io_read_write_at() { #[cfg(unix)] #[cfg_attr(any(target_os = "macos", target_os = "ios"), ignore)] fn set_get_unix_permissions() { - use std::os::unix::fs::PermissionsExt; + use cap_std::fs::PermissionsExt; let tmpdir = tmpdir(); let filename = "set_get_unix_permissions";