One Logo Pool Ball
System · IOS API REFERENCE

FileDescriptor.OpenOptions

struct · iOS 14.0+ · SDK 27.1

@frozen struct OpenOptions

Options that specify behavior for a newly-opened file.

Members (17)

get · iOS 14.0+

sharedLock

TypeScript
get sharedLock(): FileDescriptor_OpenOptions
Swift declaration
static var sharedLock: FileDescriptor.OpenOptions { get }

Indicates that opening the file atomically obtains a shared lock on the file. Setting this option or the ``exclusiveLock`` option obtains a lock with `flock(2)` semantics. If you're creating a file using the ``create`` option, the request for the lock always succeeds except on file systems that don't support locking. The corresponding C constant is `O_SHLOCK`.

get · iOS 14.0+

closeOnExec

TypeScript
get closeOnExec(): FileDescriptor_OpenOptions
Swift declaration
static var closeOnExec: FileDescriptor.OpenOptions { get }

Indicates that executing a program closes the file. Normally, file descriptors remain open across calls to the `exec(2)` family of functions. If you specify this option, the file descriptor is closed when replacing this process with another process. The state of the file descriptor flags can be inspected using `F_GETFD`, as described in the `fcntl(2)` man page. The corresponding C constant is `O_CLOEXEC`.

get · iOS 14.0+

description

TypeScript
getDescription($self: FileDescriptor_OpenOptions): string
Swift declaration
var description: String { get }

A textual representation of the open options.

get · iOS 14.0+

nonBlocking

TypeScript
get nonBlocking(): FileDescriptor_OpenOptions
Swift declaration
static var nonBlocking: FileDescriptor.OpenOptions { get }

Indicates that opening the file doesn't wait for the file or device to become available. If this option is specified, the system doesn't wait for the device or file to be ready or available. If the <doc:FileDescriptor/open(_:_:options:permissions:retryOnInterrupt:)-2266j> call would result in the process being blocked for some reason, that method returns immediately. This flag also has the effect of making all subsequent input and output operations on the open file nonblocking. The corresponding C constant is `O_NONBLOCK`.

get · iOS 14.0+

exclusiveLock

TypeScript
get exclusiveLock(): FileDescriptor_OpenOptions
Swift declaration
static var exclusiveLock: FileDescriptor.OpenOptions { get }

Indicates that opening the file atomically obtains an exclusive lock. Setting this option or the ``sharedLock`` option. obtains a lock with `flock(2)` semantics. If you're creating a file using the ``create`` option, the request for the lock always succeeds except on file systems that don't support locking. The corresponding C constant is `O_EXLOCK`.

get · iOS 14.0+

exclusiveCreate

TypeScript
get exclusiveCreate(): FileDescriptor_OpenOptions
Swift declaration
static var exclusiveCreate: FileDescriptor.OpenOptions { get }

Indicates that opening the file creates the file, expecting that it doesn't exist. If this option and ``create`` are both specified and the file exists, <doc:FileDescriptor/open(_:_:options:permissions:retryOnInterrupt:)-2266j> returns an error instead of creating the file. You can use this, for example, to implement a simple exclusive-access locking mechanism. If this option and ``create`` are both specified and the last component of the file's path is a symbolic link, <doc:FileDescriptor/open(_:_:options:permissions:retryOnInterrupt:)-2266j> fails even if the symbolic link points to a nonexistent name. The corresponding C constant is `O_EXCL`.

get · iOS 14.0+

debugDescription

TypeScript
getDebugDescription($self: FileDescriptor_OpenOptions): string
Swift declaration
var debugDescription: String { get }

A textual representation of the open options, suitable for debugging.

get · iOS 14.0+

append

TypeScript
get append(): FileDescriptor_OpenOptions
Swift declaration
static var append: FileDescriptor.OpenOptions { get }

Indicates that each write operation appends to the file. If this option is specified, each time you write to the file, the new data is written at the end of the file, after all existing file data. The corresponding C constant is `O_APPEND`.

get · iOS 14.0+

create

TypeScript
get create(): FileDescriptor_OpenOptions
Swift declaration
static var create: FileDescriptor.OpenOptions { get }

Indicates that opening the file creates the file if it doesn't exist. The corresponding C constant is `O_CREAT`.

get · iOS 14.0+

symlink

TypeScript
get symlink(): FileDescriptor_OpenOptions
Swift declaration
static var symlink: FileDescriptor.OpenOptions { get }

Indicates that opening the file opens symbolic links instead of following them. If you specify this option and the file path you pass to <doc:FileDescriptor/open(_:_:options:permissions:retryOnInterrupt:)-2266j> is a symbolic link, then the link itself is opened instead of what it links to. The corresponding C constant is `O_SYMLINK`.

get · iOS 14.0+

noFollow

TypeScript
get noFollow(): FileDescriptor_OpenOptions
Swift declaration
static var noFollow: FileDescriptor.OpenOptions { get }

Indicates that opening the file doesn't follow symlinks. If you specify this option and the file path you pass to <doc:FileDescriptor/open(_:_:options:permissions:retryOnInterrupt:)-2266j> is a symbolic link, then that open operation fails. The corresponding C constant is `O_NOFOLLOW`.

init · iOS 14.0+

init

TypeScript
init(rawValue: number): FileDescriptor_OpenOptions
Swift declaration
init(rawValue: CInt)

Create a strongly-typed options value from raw C options.

get · iOS 14.0+

rawValue

TypeScript
getRawValue($self: FileDescriptor_OpenOptions): number
Swift declaration
var rawValue: CInt

The raw C options.

set · iOS 14.0+

rawValue

TypeScript
setRawValue($self: FileDescriptor_OpenOptions, value: number): void
Swift declaration
var rawValue: CInt

The raw C options.

get · iOS 14.0+

truncate

TypeScript
get truncate(): FileDescriptor_OpenOptions
Swift declaration
static var truncate: FileDescriptor.OpenOptions { get }

Indicates that opening the file truncates the file if it exists. If this option is specified and the file exists, the file is truncated to zero bytes before any other operations are performed. The corresponding C constant is `O_TRUNC`.

get · iOS 14.0+

directory

TypeScript
get directory(): FileDescriptor_OpenOptions
Swift declaration
static var directory: FileDescriptor.OpenOptions { get }

Indicates that opening the file only succeeds if the file is a directory. If you specify this option and the file path you pass to <doc:FileDescriptor/open(_:_:options:permissions:retryOnInterrupt:)-2266j> is a not a directory, then that open operation fails. The corresponding C constant is `O_DIRECTORY`.

get · iOS 14.0+

eventOnly

TypeScript
get eventOnly(): FileDescriptor_OpenOptions
Swift declaration
static var eventOnly: FileDescriptor.OpenOptions { get }

Indicates that opening the file monitors a file for changes. Specify this option when opening a file for event notifications, such as a file handle returned by the `kqueue(2)` function, rather than for reading or writing. Files opened with this option don't prevent their containing volume from being unmounted. The corresponding C constant is `O_EVTONLY`.

Skipped declarations

No declarations were skipped in this snapshot.

All System types →