---
title: "resize(to:retryOnInterrupt:)"
framework: system
role: symbol
role_heading: Instance Method
path: "system/filedescriptor/resize(to:retryoninterrupt:)"
---

# resize(to:retryOnInterrupt:)

Truncates or extends the file referenced by this file descriptor.

## Declaration

```swift
func resize(to newSize: Int64, retryOnInterrupt: Bool = true) throws
```

## Parameters

- `newSize`: The length in bytes to resize the file to.
- `retryOnInterrupt`: Whether to retry the write operation if it throws doc://com.apple.SwiftSystem/documentation/System/Errno/interrupted. The default is true. Pass false to try only once and throw an error upon interruption.

## Discussion

Discussion The file referenced by this file descriptor will by truncated (or extended) to newSize. If the current size of the file exceeds newSize, any extra data is discarded. If the current size of the file is smaller than newSize, the file is extended and filled with zeros to the provided size. This function requires that the file has been opened for writing. note: This function does not modify the current offset for any open file descriptors associated with the file. The corresponding C function is ftruncate.
