Fields

mode: OpenMode = .read_only,
lock: Lock = .none,

Open the file with an advisory lock to coordinate with other processes accessing it at the same time. An exclusive lock will prevent other processes from acquiring a lock. A shared lock will prevent other processes from acquiring a exclusive lock, but does not prevent other process from getting their own shared locks.

The lock is advisory, except on Linux in very specific circumstances1. This means that a process that does not respect the locking API can still get access to the file, despite the lock.

On these operating systems, the lock is acquired atomically with opening the file:

  • Darwin
  • DragonFlyBSD
  • FreeBSD
  • Haiku
  • NetBSD
  • OpenBSD On these operating systems, the lock is acquired via a separate syscall after opening the file:
  • Linux
  • Windows
lock_nonblocking: bool = false,

Sets whether or not to wait until the file is locked to return. If set to true, error.WouldBlock will be returned. Otherwise, the file will wait until the file is available to proceed. In async I/O mode, non-blocking at the OS level is determined by intended_io_mode, and true means error.WouldBlock is returned, and false means error.WouldBlock is handled by the event loop.

intended_io_mode: io.ModeOverride = io.default_mode,

Setting this to .blocking prevents O.NONBLOCK from being passed even if std.io.is_async. It allows the use of nosuspend when calling functions related to opening the file, reading, writing, and locking.

allow_ctty: bool = false,

Set this to allow the opened file to automatically become the controlling TTY for the current process.

Functions

fn isRead(self: OpenFlags) bool

No documentation provided.

fn isWrite(self: OpenFlags) bool

No documentation provided.