---
title: "withFileStream(fd:automaticClose:_:)"
framework: applearchive
role: symbol
role_heading: Type Method
path: "applearchive/archivebytestream/withfilestream(fd:automaticclose:_:)"
---

# withFileStream(fd:automaticClose:_:)

Calls the given closure with a file stream created from the specified file descriptor.

## Declaration

```swift
static func withFileStream<E>(fd: FileDescriptor, automaticClose: Bool = true, _ body: (ArchiveByteStream) throws -> E) throws -> E
```

## Parameters

- `fd`: The file descriptor that you have previously opened with open(2).
- `automaticClose`: A Boolean value that specifies whether to close the file descriptor when you close the stream.
- `body`: A closure with the archive byte stream passed as a parameter.

## Return Value

Return Value The result of the closure.

## See Also

### File Streaming

- [fileStream(fd:automaticClose:)](applearchive/archivebytestream/filestream(fd:automaticclose:).md)
- [fileStream(path:mode:options:permissions:)](applearchive/archivebytestream/filestream(path:mode:options:permissions:).md)
- [withFileStream(path:mode:options:permissions:_:)](applearchive/archivebytestream/withfilestream(path:mode:options:permissions:_:).md)
- [temporaryFileStream()](applearchive/archivebytestream/temporaryfilestream().md)
- [withTemporaryFileStream(_:)](applearchive/archivebytestream/withtemporaryfilestream(_:).md)
