---
title: FileDescriptor
framework: system
role: symbol
role_heading: Structure
path: system/filedescriptor
---

# FileDescriptor

An abstract handle to an input or output data resource, such as a file or a socket.

## Declaration

```swift
@frozen struct FileDescriptor
```

## Overview

Overview You are responsible for managing the lifetime and validity of FileDescriptor values, in the same way as you manage a raw C file handle.

## Topics

### Creating a File Descriptor

- [init(rawValue:)](system/filedescriptor/init(rawvalue:).md)
- [rawValue](system/filedescriptor/rawvalue.md)

### Opening a File

- [open(_:_:options:permissions:retryOnInterrupt:)](system/filedescriptor/open(_:_:options:permissions:retryoninterrupt:)-4ql4b.md)
- [open(_:_:options:permissions:retryOnInterrupt:)](system/filedescriptor/open(_:_:options:permissions:retryoninterrupt:)-5t3xn.md)
- [FileDescriptor.AccessMode](system/filedescriptor/accessmode.md)
- [FileDescriptor.OpenOptions](system/filedescriptor/openoptions.md)

### Reading From a File

- [read(into:retryOnInterrupt:)](system/filedescriptor/read(into:retryoninterrupt:).md)
- [read(fromAbsoluteOffset:into:retryOnInterrupt:)](system/filedescriptor/read(fromabsoluteoffset:into:retryoninterrupt:).md)

### Changing a File’s Offset

- [seek(offset:from:)](system/filedescriptor/seek(offset:from:).md)
- [FileDescriptor.SeekOrigin](system/filedescriptor/seekorigin.md)

### Writing To A File

- [write(_:retryOnInterrupt:)](system/filedescriptor/write(_:retryoninterrupt:).md)
- [write(toAbsoluteOffset:_:retryOnInterrupt:)](system/filedescriptor/write(toabsoluteoffset:_:retryoninterrupt:).md)
- [writeAll(_:)](system/filedescriptor/writeall(_:).md)
- [writeAll(toAbsoluteOffset:_:)](system/filedescriptor/writeall(toabsoluteoffset:_:).md)

### Closing a File

- [close()](system/filedescriptor/close().md)
- [closeAfter(_:)](system/filedescriptor/closeafter(_:).md)

### Structures

- [FileDescriptor.DuplicateOptions](system/filedescriptor/duplicateoptions.md)
- [FileDescriptor.PipeOptions](system/filedescriptor/pipeoptions.md)

### Instance Methods

- [duplicate(as:options:retryOnInterrupt:)](system/filedescriptor/duplicate(as:options:retryoninterrupt:).md)
- [duplicate(as:retryOnInterrupt:)](system/filedescriptor/duplicate(as:retryoninterrupt:).md)
- [resize(to:retryOnInterrupt:)](system/filedescriptor/resize(to:retryoninterrupt:).md)
- [stat(retryOnInterrupt:)](system/filedescriptor/stat(retryoninterrupt:).md)

### Type Properties

- [standardError](system/filedescriptor/standarderror.md)
- [standardInput](system/filedescriptor/standardinput.md)
- [standardOutput](system/filedescriptor/standardoutput.md)

### Type Methods

- [pipe()](system/filedescriptor/pipe().md)
- [pipe(options:)](system/filedescriptor/pipe(options:).md)

## Relationships

### Conforms To

- [BitwiseCopyable](swift/bitwisecopyable.md)
- [Copyable](swift/copyable.md)
- [Decodable](swift/decodable.md)
- [Encodable](swift/encodable.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [RawRepresentable](swift/rawrepresentable.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Files

- [FilePath](system/filepath.md)
- [FilePermissions](system/filepermissions.md)
