<!--
{
  "documentType" : "article",
  "framework" : "System",
  "identifier" : "/documentation/System/adopting-file-operations",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Adopting Swift File Operations"
}
-->

# Adopting Swift File Operations

Migrate existing C code to Swift, using the file operations provided by the System module.

## Discussion

The C functions for file operations map to Swift as follows:

- `close` ⟶ [`close()`](/documentation/System/FileDescriptor/close())
- `lseek` ⟶ [`seek(offset:from:)`](/documentation/System/FileDescriptor/seek(offset:from:))  <!-- Has private overload, which confuses the link resolver -->
- `open` ⟶ [`open(_:_:options:permissions:retryOnInterrupt:)`](/documentation/System/FileDescriptor/open(_:_:options:permissions:retryOnInterrupt:)-4ql4b)
- `pread` ⟶ [`read(fromAbsoluteOffset:into:retryOnInterrupt:)`](/documentation/System/FileDescriptor/read(fromAbsoluteOffset:into:retryOnInterrupt:))
- `pwrite` ⟶ [`write(toAbsoluteOffset:_:retryOnInterrupt:)`](/documentation/System/FileDescriptor/write(toAbsoluteOffset:_:retryOnInterrupt:))
- `read` ⟶ [`read(into:retryOnInterrupt:)`](/documentation/System/FileDescriptor/read(into:retryOnInterrupt:))
- `write` ⟶ [`write(_:retryOnInterrupt:)`](/documentation/System/FileDescriptor/write(_:retryOnInterrupt:))

---

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)