Source
pub const dirent = switch (native_os) {
.linux, .emscripten => extern struct {
ino: c_uint,
off: c_uint,
reclen: c_ushort,
type: u8,
name: [256]u8,
},
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
ino: u64,
seekoff: u64,
reclen: u16,
namlen: u16,
type: u8,
name: [1024]u8,
},
.freebsd => extern struct {
/// File number of entry.
fileno: ino_t,
/// Directory offset of entry.
off: off_t,
/// Length of this record.
reclen: u16,
/// File type, one of DT_.
type: u8,
pad0: u8 = 0,
/// Length of the name member.
namlen: u16,
pad1: u16 = 0,
/// Name of entry.
name: [255:0]u8,
},
.solaris, .illumos => extern struct {
/// Inode number of entry.
ino: ino_t,
/// Offset of this entry on disk.
off: off_t,
/// Length of this record.
reclen: u16,
/// File name.
name: [MAXNAMLEN:0]u8,
},
.netbsd => extern struct {
fileno: ino_t,
reclen: u16,
namlen: u16,
type: u8,
name: [MAXNAMLEN:0]u8,
},
.dragonfly => extern struct {
fileno: c_ulong,
namlen: u16,
type: u8,
unused1: u8,
unused2: u32,
name: [256]u8,
pub fn reclen(self: dirent) u16 {
return (@offsetOf(dirent, "name") + self.namlen + 1 + 7) & ~@as(u16, 7);
}
},
.openbsd => extern struct {
fileno: ino_t,
off: off_t,
reclen: u16,
type: u8,
namlen: u8,
_: u32 align(1) = 0,
name: [MAXNAMLEN:0]u8,
},
// https://github.com/SerenityOS/serenity/blob/abc150085f532f123b598949218893cb272ccc4c/Userland/Libraries/LibC/dirent.h#L14-L20
.serenity => extern struct {
ino: ino_t,
off: off_t,
reclen: c_ushort,
type: u8,
name: [256:0]u8,
},
else => void,
}