feature. See also
. The project being documented here (as the example) is the Zig library itself.
c.Stat
pub const Stat = switch (native_os)
File
Code
pub const Stat = switch (native_os) {
.emscripten => emscripten.Stat,
.wasi => extern struct {
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,
};
}
},
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => 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,
.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;
}
},
.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,
}