<!--
{
  "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/write(toAbsoluteOffset:_:retryOnInterrupt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "System"
    ],
    "preciseIdentifier" : "s:6System14FileDescriptorV5write16toAbsoluteOffset_16retryOnInterruptSis5Int64V_SWSbtKF"
  },
  "title" : "write(toAbsoluteOffset:_:retryOnInterrupt:)"
}
-->

# write(toAbsoluteOffset:_:retryOnInterrupt:)

Writes the contents of a buffer at the specified offset.

```
func write(toAbsoluteOffset offset: Int64, _ buffer: UnsafeRawBufferPointer, retryOnInterrupt: Bool = true) throws -> Int
```

## Parameters

`offset`

The file offset where writing begins.

`buffer`

The region of memory that contains the data being written.

`retryOnInterrupt`

Whether to retry the write operation
if it throws [`interrupted`](/documentation/System/Errno/interrupted).
The default is `true`.
Pass `false` to try only once and throw an error upon interruption.

## Return Value

The number of bytes that were written.

## Discussion

Unlike [`write(_:retryOnInterrupt:)`](/documentation/System/FileDescriptor/write(_:retryOnInterrupt:)),
this method leaves the file’s existing offset unchanged.

The corresponding C function is `pwrite`.

---

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)