open(atPath:mode:options:permissions:retryOnInterrupt:)

Opens or creates a file for reading or writing.

FileDescriptor+Syscalls.swift:46

This declaration is gated by at least one @_spi attribute.

func open(atPath path: FilePath, mode: FileDescriptor.AccessMode, options: FileDescriptor.OpenOptions, permissions: FilePermissions?, retryOnInterrupt: Bool = true) -> Result<FileDescriptor, Errno>

Parameters

path

The location of the file to open. If the path is relative then the file is opened relative to the descriptor.

mode

The read and write access to use.

options

The behavior for opening the file.

permissions

The file permissions to use for created files.

retryOnInterrupt

Whether to retry the operation if it throws Errno.interrupted. The default is true. Pass false to try only once and throw an error upon interruption.

Returns

A file descriptor for the open file.

The corresponding C function is fdopenat.