<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppleArchive",
  "identifier" : "/documentation/AppleArchive/ArchiveStream",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Apple Archive"
    ],
    "preciseIdentifier" : "s:12AppleArchive0B6StreamC"
  },
  "title" : "ArchiveStream"
}
-->

# ArchiveStream

An archive stream that reads from and writes to data blobs

```
class ArchiveStream
```

## Topics

### Creating an Archive Stream

[`init(object: _AAOptionalObjectWrapperWithFilter<_AAArchiveStreamTraits>.AAType?, owned: Bool, messageProc: ArchiveHeader._EntryFilterWrapper?)`](/documentation/AppleArchive/ArchiveStream/init(object:owned:messageProc:))

Returns a new archive stream from the specified traits and entry message processing callback.

### Reading and Writing Blobs

### Reading and Writing Headers

### Writing Directory Contents

[`func writeDirectoryContents(archiveFrom: FilePath, path: FilePath?, keySet: ArchiveHeader.FieldKeySet, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int) throws`](/documentation/AppleArchive/ArchiveStream/writeDirectoryContents(archiveFrom:path:keySet:selectUsing:flags:threadCount:))

Writes all entries from a directory to the archive stream.

### Using Archive Streams

### Extracting Data

[`static func extractStream(extractingTo: FilePath, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int) -> ArchiveStream?`](/documentation/AppleArchive/ArchiveStream/extractStream(extractingTo:selectUsing:flags:threadCount:))

Opens an extract output archive stream.

[`static func withExtractStream<E>(extractingTo: FilePath, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int, (ArchiveStream) throws -> E) throws -> E`](/documentation/AppleArchive/ArchiveStream/withExtractStream(extractingTo:selectUsing:flags:threadCount:_:))

Calls the given closure with an extract output archive stream.

### Encoding Data

[`static func encodeStream(writingTo: ArchiveByteStream, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int) -> ArchiveStream?`](/documentation/AppleArchive/ArchiveStream/encodeStream(writingTo:selectUsing:flags:threadCount:))

Opens an encode output archive stream.

[`static func withEncodeStream<E>(writingTo: ArchiveByteStream, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int, (ArchiveStream) throws -> E) throws -> E`](/documentation/AppleArchive/ArchiveStream/withEncodeStream(writingTo:selectUsing:flags:threadCount:_:))

Calls the given closure with an encode output archive stream.

### Decoding Data

[`static func decodeStream(readingFrom: ArchiveByteStream, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int) -> ArchiveStream?`](/documentation/AppleArchive/ArchiveStream/decodeStream(readingFrom:selectUsing:flags:threadCount:))

Opens a decode input archive stream.

[`static func withDecodeStream<E>(readingFrom: ArchiveByteStream, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int, (ArchiveStream) throws -> E) throws -> E`](/documentation/AppleArchive/ArchiveStream/withDecodeStream(readingFrom:selectUsing:flags:threadCount:_:))

Calls the given closure with a decode input archive stream.

### Converting Data

[`static func convertStream(writingTo: ArchiveStream, insertKeySet: ArchiveHeader.FieldKeySet, removeKeySet: ArchiveHeader.FieldKeySet, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int) -> ArchiveStream?`](/documentation/AppleArchive/ArchiveStream/convertStream(writingTo:insertKeySet:removeKeySet:selectUsing:flags:threadCount:))

Opens a convert output archive stream.

[`static func withConvertStream<E>(writingTo: ArchiveStream, insertKeySet: ArchiveHeader.FieldKeySet, removeKeySet: ArchiveHeader.FieldKeySet, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int, (ArchiveStream) throws -> E) throws -> E`](/documentation/AppleArchive/ArchiveStream/withConvertStream(writingTo:insertKeySet:removeKeySet:selectUsing:flags:threadCount:_:))

Calls the given closure with a convert output archive stream.

### Processing Data

[`static func process(readingFrom: ArchiveStream, writingTo: ArchiveStream, selectUsing: ArchiveHeader.EntryFilter?, flags: ArchiveFlags, threadCount: Int) throws -> Int`](/documentation/AppleArchive/ArchiveStream/process(readingFrom:writingTo:selectUsing:flags:threadCount:))

Processes archive elements between two archive streams.

### Using Custom Streams

[`static func customStream<C>(instance: C) -> ArchiveStream?`](/documentation/AppleArchive/ArchiveStream/customStream(instance:))

Returns a new archive stream instance mapped to an object that conforms to the archive stream protocol.

[`static func withStream<C, E>(wrapping: C, (ArchiveStream) throws -> E) throws -> E`](/documentation/AppleArchive/ArchiveStream/withStream(wrapping:_:))

Calls the given closure with an archive stream instance mapped to an object that conforms to the archive stream protocol.

## Relationships

### Conforms To

[`ArchiveStreamProtocol`](/documentation/AppleArchive/ArchiveStreamProtocol)

---

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)