Function accessZ [src]

Same as access except the path parameter is null-terminated.

Prototype

pub fn accessZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) AccessError!void

Parameters

self: Dirsub_path: [*:0]const u8flags: File.OpenFlags

Possible Errors

AccessDenied AccessError
BadPathName AccessError
FileBusy AccessError
FileNotFound AccessError
InputOutput AccessError
InvalidUtf8 AccessError

WASI-only; file paths must be valid UTF-8.

InvalidWtf8 AccessError

Windows-only; file paths provided by the user must be valid WTF-8. https://simonsapin.github.io/wtf-8/

NameTooLong AccessError
PermissionDenied AccessError
ReadOnlyFileSystem AccessError
SymLinkLoop AccessError
SystemResources AccessError
Unexpected UnexpectedError

The Operating System returned an undocumented error code.

This error is in theory not possible, but it would be better to handle this error than to invoke undefined behavior.

When this error code is observed, it usually means the Zig Standard Library needs a small patch to add the error code to the error set for the respective function.

Source

pub fn accessZ(self: Dir, sub_path: [*:0]const u8, flags: File.OpenFlags) AccessError!void { if (native_os == .windows) { const sub_path_w = try windows.cStrToPrefixedFileW(self.fd, sub_path); return self.accessW(sub_path_w.span().ptr, flags); } const os_mode = switch (flags.mode) { .read_only => @as(u32, posix.F_OK), .write_only => @as(u32, posix.W_OK), .read_write => @as(u32, posix.R_OK | posix.W_OK), }; const result = posix.faccessatZ(self.fd, sub_path, os_mode, 0); return result; }