feature. See also
. The project being documented here (as the example) is the Zig library itself.
Dispatch.dirOpenDir
fn dirOpenDir(
userdata: ?*anyopaque,
dir: Dir,
sub_path: []const u8,
options: Dir.OpenOptions,
) Dir.OpenError!Dir
File
Code
fn dirOpenDir(
userdata: ?*anyopaque,
dir: Dir,
sub_path: []const u8,
options: Dir.OpenOptions,
) Dir.OpenError!Dir {
const ev: *Evented = @ptrCast(@alignCast(userdata));
_ = ev;
var path_buffer: [c.PATH_MAX]u8 = undefined;
const sub_path_posix = try pathToPosix(sub_path, &path_buffer);
const flags: c.O = .{
.ACCMODE = .RDONLY,
.NOFOLLOW = !options.follow_symlinks,
.DIRECTORY = true,
.CLOEXEC = true,
};
while (true) {
const rc = c.openat(dir.handle, sub_path_posix, flags);
switch (c.errno(rc)) {
.SUCCESS => return .{ .handle = @intCast(rc) },
.INTR => {},
.INVAL => return error.BadPathName,
.ACCES => return error.AccessDenied,
.LOOP => return error.SymLinkLoop,
.MFILE => return error.ProcessFdQuotaExceeded,
.NAMETOOLONG => return error.NameTooLong,
.NFILE => return error.SystemFdQuotaExceeded,
.NODEV => return error.NoDevice,
.NOENT => return error.FileNotFound,
.NOMEM => return error.SystemResources,
.NOTDIR => return error.NotDir,
.PERM => return error.PermissionDenied,
.NXIO => return error.NoDevice,
.ILSEQ => return error.BadPathName,
.FAULT => |err| return errnoBug(err),
.BADF => |err| return errnoBug(err),
.BUSY => |err| return errnoBug(err),
else => |err| return unexpectedErrno(err),
}
}
}