Those functions in std.os.linux
are direct syscall wrappers (see, for example, the Source Code of std.os.linux.open
for what I mean). Some relevant links:
- What are the reasons for exposing errno in std.os.linux syscalls?
- std.os.foo functions return usize error codes instead of error unions · Issue #17870 · ziglang/zig · GitHub
The closest equivalent to what you’re looking for would be in std.posix
, e.g. std.posix.open
Also worth noting that when working with the filesystem and writing cross-platform code, the APIs in std.fs
are generally preferred over std.posix
. That would look something like:
const file = try std.fs.cwd().openFile("some/path/file.txt", .{});
defer file.close();
// ...