Open and possibly create a file. Keeps trying if it gets interrupted.
file_path is relative to the open directory handle dir_fd.
On Windows, file_path should be encoded as WTF-8.
On WASI, file_path should be encoded as valid UTF-8.
On other platforms, file_path is an opaque sequence of bytes with no particular encoding.
See also openatZ.
pub fn openat(dir_fd: fd_t, file_path: []const u8, flags: O, mode: mode_t) OpenError!fd_t
pub fn openat(dir_fd: fd_t, file_path: []const u8, flags: O, mode: mode_t) OpenError!fd_t {
if (native_os == .windows) {
@compileError("Windows does not support POSIX; use Windows-specific API or cross-platform std.fs API");
} else if (native_os == .wasi and !builtin.link_libc) {
@compileError("use std.Io instead");
}
const file_path_c = try toPosixPath(file_path);
return openatZ(dir_fd, &file_path_c, flags, mode);
}