---
title: "withFileStream(path:mode:options:permissions:_:)"
framework: applearchive
role: symbol
role_heading: Type Method
path: "applearchive/archivebytestream/withfilestream(path:mode:options:permissions:_:)"
---

# withFileStream(path:mode:options:permissions:_:)

Calls the given closure with a file stream.

## Declaration

```swift
static func withFileStream<E>(path: FilePath, mode: FileDescriptor.AccessMode, options: FileDescriptor.OpenOptions, permissions: FilePermissions, _ body: (ArchiveByteStream) throws -> E) throws -> E
```

## Parameters

- `path`: The file path.
- `mode`: The file descriptor access mode.
- `options`: The file descriptor options that specify behavior on opening a file.
- `permissions`: The file permission bits that govern access to a file.
- `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)
- [withFileStream(fd:automaticClose:_:)](applearchive/archivebytestream/withfilestream(fd:automaticclose:_:).md)
- [fileStream(path:mode:options:permissions:)](applearchive/archivebytestream/filestream(path:mode:options:permissions:).md)
- [temporaryFileStream()](applearchive/archivebytestream/temporaryfilestream().md)
- [withTemporaryFileStream(_:)](applearchive/archivebytestream/withtemporaryfilestream(_:).md)
