---
title: truncate
framework: system
role: symbol
role_heading: Type Property
path: system/filedescriptor/openoptions/truncate
---

# truncate

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

## Declaration

```swift
static var truncate: FileDescriptor.OpenOptions { get }
```

## Mentioned in

Adopting Swift File Options

## Discussion

Discussion 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.

## See Also

### Specifying Options

- [append](system/filedescriptor/openoptions/append.md)
- [closeOnExec](system/filedescriptor/openoptions/closeonexec.md)
- [create](system/filedescriptor/openoptions/create.md)
- [eventOnly](system/filedescriptor/openoptions/eventonly.md)
- [exclusiveCreate](system/filedescriptor/openoptions/exclusivecreate.md)
- [exclusiveLock](system/filedescriptor/openoptions/exclusivelock.md)
- [noFollow](system/filedescriptor/openoptions/nofollow.md)
- [nonBlocking](system/filedescriptor/openoptions/nonblocking.md)
- [sharedLock](system/filedescriptor/openoptions/sharedlock.md)
- [symlink](system/filedescriptor/openoptions/symlink.md)
