Function kind [src]
Returns the Kind of the file
Prototype
pub fn kind(self: Self) Kind
Parameters
self: Self
Source
pub fn kind(self: Self) Kind {
if (builtin.os.tag == .wasi and !builtin.link_libc) return switch (self.stat.filetype) {
.BLOCK_DEVICE => .block_device,
.CHARACTER_DEVICE => .character_device,
.DIRECTORY => .directory,
.SYMBOLIC_LINK => .sym_link,
.REGULAR_FILE => .file,
.SOCKET_STREAM, .SOCKET_DGRAM => .unix_domain_socket,
else => .unknown,
};
const m = self.stat.mode & posix.S.IFMT;
switch (m) {
posix.S.IFBLK => return .block_device,
posix.S.IFCHR => return .character_device,
posix.S.IFDIR => return .directory,
posix.S.IFIFO => return .named_pipe,
posix.S.IFLNK => return .sym_link,
posix.S.IFREG => return .file,
posix.S.IFSOCK => return .unix_domain_socket,
else => {},
}
if (builtin.os.tag.isSolarish()) switch (m) {
posix.S.IFDOOR => return .door,
posix.S.IFPORT => return .event_port,
else => {},
};
return .unknown;
}