Structure
ArArchiveWriter
public struct ArArchiveWriter
ArArchiveWriter
creates ar
files.
import Foundation
var writer = ArArchiveWriter()
writer.addFile(header: Header(name: "hello.txt", modificationTime: Int(Date().timeIntervalSince1970)), contents: "Hello, World!")
let data = Data(writer.finalize())
Initializers
init(variant:)
public init(variant: Variant = .common)
Properties
Methods
addFile(header:contents:)
public mutating func addFile(header: Header, contents: [UInt8])
Add a file to the archive.
Parameters
Name | Type | Description |
---|---|---|
header | Header |
The header that describes the file. |
contents | [UInt8] |
The raw bytes of the file. |
addFile(header:contents:)
public mutating func addFile(header: Header, contents: String)
Wrapper function around ArArchiveWriter.addFile(header:contents:)
which allows you to pass in a String
instead of raw bytes..
finalize(clear:)
public mutating func finalize(clear: Bool = true) -> [UInt8]
Creates an archive and returns the bytes of the created archive.
Parameters
Name | Type | Description |
---|---|---|
clear | Bool |
Whether the data in |
Returns
The bytes of the created archive.