Skip to content
Merged
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
120 changes: 63 additions & 57 deletions library/std/src/sys/fs/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,31 @@ use libc::fstatat as fstatat64;
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))]
use libc::fstatat64;
#[cfg(any(
target_os = "aix",
target_os = "android",
target_os = "solaris",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "redox",
target_os = "illumos",
target_os = "aix",
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita",
all(target_os = "linux", target_env = "musl"),
))]
use libc::readdir as readdir64;
#[cfg(not(any(
target_os = "aix",
target_os = "android",
target_os = "linux",
target_os = "solaris",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "hurd",
target_os = "illumos",
target_os = "l4re",
target_os = "fuchsia",
target_os = "redox",
target_os = "aix",
target_os = "linux",
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "hurd",
)))]
use libc::readdir_r as readdir64_r;
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "hurd"))]
Expand Down Expand Up @@ -271,16 +273,17 @@ unsafe impl Send for Dir {}
unsafe impl Sync for Dir {}

#[cfg(any(
target_os = "aix",
target_os = "android",
target_os = "linux",
target_os = "solaris",
target_os = "illumos",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "redox",
target_os = "aix",
target_os = "hurd",
target_os = "illumos",
target_os = "linux",
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "hurd",
))]
pub struct DirEntry {
dir: Arc<InnerReadDir>,
Expand All @@ -295,16 +298,17 @@ pub struct DirEntry {
// we're not using the immediate `d_name` on these targets. Keeping this as an
// `entry` field in `DirEntry` helps reduce the `cfg` boilerplate elsewhere.
#[cfg(any(
target_os = "aix",
target_os = "android",
target_os = "linux",
target_os = "solaris",
target_os = "illumos",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "redox",
target_os = "aix",
target_os = "hurd",
target_os = "illumos",
target_os = "linux",
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "hurd",
))]
struct dirent64_min {
d_ino: u64,
Expand All @@ -319,16 +323,17 @@ struct dirent64_min {
}

#[cfg(not(any(
target_os = "aix",
target_os = "android",
target_os = "linux",
target_os = "solaris",
target_os = "illumos",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "redox",
target_os = "aix",
target_os = "hurd",
target_os = "illumos",
target_os = "linux",
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "hurd",
)))]
pub struct DirEntry {
dir: Arc<InnerReadDir>,
Expand Down Expand Up @@ -698,16 +703,17 @@ impl Iterator for ReadDir {
type Item = io::Result<DirEntry>;

#[cfg(any(
target_os = "aix",
target_os = "android",
target_os = "linux",
target_os = "solaris",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "redox",
target_os = "hurd",
target_os = "illumos",
target_os = "aix",
target_os = "linux",
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "hurd",
))]
fn next(&mut self) -> Option<io::Result<DirEntry>> {
use crate::sys::os::{errno, set_errno};
Expand Down Expand Up @@ -768,6 +774,9 @@ impl Iterator for ReadDir {
// only access those bytes.
#[cfg(not(target_os = "vita"))]
let entry = dirent64_min {
#[cfg(target_os = "freebsd")]
d_ino: (*entry_ptr).d_fileno,
#[cfg(not(target_os = "freebsd"))]
d_ino: (*entry_ptr).d_ino as u64,
#[cfg(not(any(
target_os = "solaris",
Expand All @@ -791,16 +800,17 @@ impl Iterator for ReadDir {
}

#[cfg(not(any(
target_os = "aix",
target_os = "android",
target_os = "linux",
target_os = "solaris",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "redox",
target_os = "hurd",
target_os = "illumos",
target_os = "aix",
target_os = "linux",
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita",
target_os = "hurd",
)))]
fn next(&mut self) -> Option<io::Result<DirEntry>> {
if self.end_of_stream {
Expand Down Expand Up @@ -970,36 +980,32 @@ impl DirEntry {
}

#[cfg(any(
target_os = "linux",
target_os = "aix",
target_os = "android",
target_os = "cygwin",
target_os = "emscripten",
target_os = "android",
target_os = "solaris",
target_os = "illumos",
target_os = "haiku",
target_os = "l4re",
target_os = "fuchsia",
target_os = "redox",
target_os = "vxworks",
target_os = "espidf",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
target_os = "horizon",
target_os = "vita",
target_os = "aix",
target_os = "nto",
target_os = "hurd",
target_os = "illumos",
target_os = "l4re",
target_os = "linux",
target_os = "nto",
target_os = "redox",
target_os = "rtems",
target_os = "solaris",
target_os = "vita",
target_os = "vxworks",
target_vendor = "apple",
))]
pub fn ino(&self) -> u64 {
self.entry.d_ino as u64
}

#[cfg(any(
target_os = "freebsd",
target_os = "openbsd",
target_os = "netbsd",
target_os = "dragonfly"
))]
#[cfg(any(target_os = "openbsd", target_os = "netbsd", target_os = "dragonfly"))]
pub fn ino(&self) -> u64 {
self.entry.d_fileno as u64
}
Expand All @@ -1014,7 +1020,6 @@ impl DirEntry {
#[cfg(any(
target_os = "netbsd",
target_os = "openbsd",
target_os = "freebsd",
target_os = "dragonfly",
target_vendor = "apple",
))]
Expand All @@ -1030,7 +1035,6 @@ impl DirEntry {
#[cfg(not(any(
target_os = "netbsd",
target_os = "openbsd",
target_os = "freebsd",
target_os = "dragonfly",
target_vendor = "apple",
)))]
Expand All @@ -1040,6 +1044,7 @@ impl DirEntry {

#[cfg(not(any(
target_os = "android",
target_os = "freebsd",
target_os = "linux",
target_os = "solaris",
target_os = "illumos",
Expand All @@ -1055,6 +1060,7 @@ impl DirEntry {
}
#[cfg(any(
target_os = "android",
target_os = "freebsd",
target_os = "linux",
target_os = "solaris",
target_os = "illumos",
Expand Down
Loading