<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "System",
  "identifier" : "/documentation/System/FileDescriptor/OpenOptions",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System14FileDescriptorV11OpenOptionsV"
  },
  "title" : "FileDescriptor.OpenOptions"
}
-->

# FileDescriptor.OpenOptions

Options that specify behavior for a newly-opened file.

```
@frozen struct OpenOptions
```

## Topics

### Specifying Options

[`static var append: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/append)

Indicates that each write operation appends to the file.

[`static var closeOnExec: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/closeOnExec)

Indicates that executing a program closes the file.

[`static var create: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/create)

Indicates that opening the file creates the file if it doesn’t exist.

[`static var eventOnly: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/eventOnly)

Indicates that opening the file monitors a file for changes.

[`static var exclusiveCreate: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/exclusiveCreate)

Indicates that opening the file creates the file,
expecting that it doesn’t exist.

[`static var exclusiveLock: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/exclusiveLock)

Indicates that opening the file
atomically obtains an exclusive lock.

[`static var noFollow: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/noFollow)

Indicates that opening the file doesn’t follow symlinks.

[`static var nonBlocking: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/nonBlocking)

Indicates that opening the file doesn’t
wait for the file or device to become available.

[`static var sharedLock: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/sharedLock)

Indicates that opening the file
atomically obtains a shared lock on the file.

[`static var symlink: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/symlink)

Indicates that opening the file
opens symbolic links instead of following them.

[`static var truncate: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/truncate)

Indicates that opening the file truncates the file if it exists.

### Interacting with C APIs

[`init(rawValue: CInt)`](/documentation/System/FileDescriptor/OpenOptions/init(rawValue:))

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

[`var rawValue: CInt`](/documentation/System/FileDescriptor/OpenOptions/rawValue)

The raw C options.

### Debugging

[`var description: String`](/documentation/System/FileDescriptor/OpenOptions/description)

A textual representation of the open options.

[`var debugDescription: String`](/documentation/System/FileDescriptor/OpenOptions/debugDescription)

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

### Comparing Open Options

### Encoding Open Options

### Performing Set Operations

### Type Properties

[`static var directory: FileDescriptor.OpenOptions`](/documentation/System/FileDescriptor/OpenOptions/directory)

Indicates that opening the file only succeeds if the file is a directory.

### Default Implementations

[CustomDebugStringConvertible Implementations](/documentation/System/FileDescriptor/OpenOptions/CustomDebugStringConvertible-Implementations)

[CustomStringConvertible Implementations](/documentation/System/FileDescriptor/OpenOptions/CustomStringConvertible-Implementations)

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`RawRepresentable`](/documentation/Swift/RawRepresentable)

[`Sendable`](/documentation/Swift/Sendable)

[`OptionSet`](/documentation/Swift/OptionSet)

[`Escapable`](/documentation/Swift/Escapable)

[`SetAlgebra`](/documentation/Swift/SetAlgebra)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`BitwiseCopyable`](/documentation/Swift/BitwiseCopyable)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Copyable`](/documentation/Swift/Copyable)

[`ExpressibleByArrayLiteral`](/documentation/Swift/ExpressibleByArrayLiteral)

[`Decodable`](/documentation/Swift/Decodable)

[`Encodable`](/documentation/Swift/Encodable)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)