<!--
{
  "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/exclusiveCreate",
  "metadataVersion" : "0.1.0",
  "role" : "Type Property",
  "symbol" : {
    "kind" : "Type Property",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System14FileDescriptorV11OpenOptionsV15exclusiveCreateAEvpZ"
  },
  "title" : "exclusiveCreate"
}
-->

# exclusiveCreate

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

```
static var exclusiveCreate: FileDescriptor.OpenOptions { get }
```

## Discussion

If this option and [`create`](/documentation/System/FileDescriptor/OpenOptions/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`](/documentation/System/FileDescriptor/OpenOptions/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`.

---

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)