Structure
CPIOArchiveWriter
public struct CPIOArchiveWriter
CPIOArchiveWriter
creates cpio
archives.
let writer = CPIOArchiveWriter()
let header = Header(
name: "hello.txt",
mode: FileMode(0o644),
modificationTime: Int(Date().timeIntervalSince1970)
)
writer.addFile(header: header, contents: "Hello World!")
writer.finalize()
// Use `writer.bytes`.
Initializers
init(type:)
public init(type: CPIOArchiveType = .svr4)
Creates a new CPIOArchiveWriter
.
Parameters
Name | Type | Description |
---|---|---|
type | CPIOArchiveType |
The type of |
Properties
archiveType
public let archiveType: CPIOArchiveType
The type of archive that CPIOArchiveWriter
will create.
Methods
addFile(header:contents:)
public mutating func addFile(header: Header, contents: [UInt8] = [])
Add a file to the archive.
Symlinks
Add a symlink by setting header.name
to the name you want the symlink to have, and contents
to the name of the file you want to link to.
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 CPIOArchiveWriter.addFile(header:contents:)
which allows you to pass in a String
instead of raw bytes..
Symlinks
Add a symlink by setting header.name
to the name you want the symlink to have, and contents
to the name of the file you want to link to.
finalize(clear:)
public mutating func finalize(clear: Bool = false) -> [UInt8]
Creates the archive and returns the bytes of the archive.