Source
pub const Stat = switch (native_os) {
.linux => switch (native_arch) {
.sparc64 => extern struct {
dev: u64,
__pad1: u16,
ino: ino_t,
mode: u32,
nlink: u32,
uid: u32,
gid: u32,
rdev: u64,
__pad2: u16,
size: off_t,
blksize: isize,
blocks: i64,
atim: timespec,
mtim: timespec,
ctim: timespec,
__reserved: [2]usize,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
},
.mips, .mipsel => if (builtin.target.abi.isMusl()) extern struct {
dev: dev_t,
__pad0: [2]i32,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__pad1: [2]i32,
size: off_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
blksize: blksize_t,
__pad3: i32,
blocks: blkcnt_t,
__pad4: [14]i32,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
} else extern struct {
dev: u32,
__pad0: [3]u32,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: u32,
__pad1: [3]u32,
size: off_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
blksize: blksize_t,
__pad3: u32,
blocks: blkcnt_t,
__pad4: [14]u32,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
},
.mips64, .mips64el => if (builtin.target.abi.isMusl()) extern struct {
dev: dev_t,
__pad0: [3]i32,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__pad1: [2]u32,
size: off_t,
__pad2: i32,
atim: timespec,
mtim: timespec,
ctim: timespec,
blksize: blksize_t,
__pad3: u32,
blocks: blkcnt_t,
__pad4: [14]i32,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
} else extern struct {
dev: dev_t,
__pad0: [3]u32,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
__pad1: [3]u32,
size: off_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
blksize: blksize_t,
__pad3: u32,
blocks: blkcnt_t,
__pad4: [14]i32,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
},
else => std.os.linux.Stat, // libc stat is the same as kernel stat.
},
.emscripten => emscripten.Stat,
.wasi => extern struct {
// Match wasi-libc's `struct stat` in lib/libc/include/wasm-wasi-musl/__struct_stat.h
dev: dev_t,
ino: ino_t,
nlink: nlink_t,
mode: mode_t,
uid: uid_t,
gid: gid_t,
__pad0: c_uint = 0,
rdev: dev_t,
size: off_t,
blksize: blksize_t,
blocks: blkcnt_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
__reserved: [3]c_longlong = [3]c_longlong{ 0, 0, 0 },
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
pub fn fromFilestat(st: wasi.filestat_t) Stat {
return .{
.dev = st.dev,
.ino = st.ino,
.mode = switch (st.filetype) {
.UNKNOWN => 0,
.BLOCK_DEVICE => S.IFBLK,
.CHARACTER_DEVICE => S.IFCHR,
.DIRECTORY => S.IFDIR,
.REGULAR_FILE => S.IFREG,
.SOCKET_DGRAM => S.IFSOCK,
.SOCKET_STREAM => S.IFIFO,
.SYMBOLIC_LINK => S.IFLNK,
_ => 0,
},
.nlink = st.nlink,
.size = @intCast(st.size),
.atim = timespec.fromTimestamp(st.atim),
.mtim = timespec.fromTimestamp(st.mtim),
.ctim = timespec.fromTimestamp(st.ctim),
.uid = 0,
.gid = 0,
.rdev = 0,
.blksize = 0,
.blocks = 0,
};
}
},
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
dev: i32,
mode: u16,
nlink: u16,
ino: ino_t,
uid: uid_t,
gid: gid_t,
rdev: i32,
atimespec: timespec,
mtimespec: timespec,
ctimespec: timespec,
birthtimespec: timespec,
size: off_t,
blocks: i64,
blksize: i32,
flags: u32,
gen: u32,
lspare: i32,
qspare: [2]i64,
pub fn atime(self: @This()) timespec {
return self.atimespec;
}
pub fn mtime(self: @This()) timespec {
return self.mtimespec;
}
pub fn ctime(self: @This()) timespec {
return self.ctimespec;
}
pub fn birthtime(self: @This()) timespec {
return self.birthtimespec;
}
},
.freebsd => freebsd.Stat,
.solaris, .illumos => extern struct {
dev: dev_t,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
size: off_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
blksize: blksize_t,
blocks: blkcnt_t,
fstype: [16]u8,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
},
.netbsd => extern struct {
dev: dev_t,
mode: mode_t,
ino: ino_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
birthtim: timespec,
size: off_t,
blocks: blkcnt_t,
blksize: blksize_t,
flags: u32,
gen: u32,
__spare: [2]u32,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
pub fn birthtime(self: @This()) timespec {
return self.birthtim;
}
},
.dragonfly => extern struct {
ino: ino_t,
nlink: c_uint,
dev: c_uint,
mode: c_ushort,
padding1: u16,
uid: uid_t,
gid: gid_t,
rdev: c_uint,
atim: timespec,
mtim: timespec,
ctim: timespec,
size: c_ulong,
blocks: i64,
blksize: u32,
flags: u32,
gen: u32,
lspare: i32,
qspare1: i64,
qspare2: i64,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
},
.haiku => extern struct {
dev: dev_t,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
size: off_t,
rdev: dev_t,
blksize: blksize_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
crtim: timespec,
type: u32,
blocks: blkcnt_t,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
pub fn birthtime(self: @This()) timespec {
return self.crtim;
}
},
.openbsd => extern struct {
mode: mode_t,
dev: dev_t,
ino: ino_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
size: off_t,
blocks: blkcnt_t,
blksize: blksize_t,
flags: u32,
gen: u32,
birthtim: timespec,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
pub fn birthtime(self: @This()) timespec {
return self.birthtim;
}
},
// https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/sys/stat.h#L53-L67
.serenity => extern struct {
dev: dev_t,
ino: ino_t,
mode: mode_t,
nlink: nlink_t,
uid: uid_t,
gid: gid_t,
rdev: dev_t,
size: off_t,
blksize: blksize_t,
blocks: blkcnt_t,
atim: timespec,
mtim: timespec,
ctim: timespec,
pub fn atime(self: @This()) timespec {
return self.atim;
}
pub fn mtime(self: @This()) timespec {
return self.mtim;
}
pub fn ctime(self: @This()) timespec {
return self.ctim;
}
},
else => void,
}