Zig 0.17.0-dev (Split by item)
This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig library itself.
Zig › std/ › Io/ › Dispatch.zig › fileLock
fileLock
Dispatch.fileLock
fn fileLock (userdata : ?*anyopaque , file : File , lock : File .Lock ) File .LockError !void
File
Code
fn fileLock (userdata : ?*anyopaque , file : File , lock : File .Lock ) File .LockError !void {
const ev : *Evented = @ptrCast (@alignCast (userdata ));
_ = ev ;
const operation : i32 = switch (lock ) {
.none => c .LOCK .UN ,
.shared => c .LOCK .SH ,
.exclusive => c .LOCK .EX ,
};
while (true ) switch (c .errno (c .flock (file .handle , operation ))) {
.SUCCESS => return ,
.INTR => {},
.BADF => |err | return errnoBug (err ),
.INVAL => |err | return errnoBug (err ),
.NOLCK => return error .SystemResources ,
.AGAIN => |err | return errnoBug (err ),
.OPNOTSUPP => return error .FileLocksUnsupported ,
else => |err | return unexpectedErrno (err ),
};
}