CPIOArchiveKit Documentation

Structure Header

public struct Header: Codable, Equatable  

The cpio header.

This header is placed directly before the contents of a file in the archive to provide information such as the size of the file, the file's name, it's permissions, etc.

%21 Header Header Equatable Equatable Header->Equatable Codable Codable Header->Codable

Conforms To

Codable
Equatable

Initializers

init(name:​user​ID:​group​ID:​mode:​modification​Time:​inode:​links:​dev:​rDev:​checksum:​)

public init(
		name: String,
		userID: Int = 0,
		groupID: Int = 0,
		mode: FileMode,
		modificationTime: Int,
		inode: Int? = nil,
		links: Int = 1,
		dev: (major: Int?, minor: Int?) = (nil, nil),
		rDev: (major: Int, minor: Int) = (0, 0),
		checksum: Checksum? = nil
	)  

init(from:​)

public init(from decoder: Decoder) throws  

Properties

name

public internal(set) var name: String

The file's name.

user​ID

public internal(set) var userID: Int = 0

The ID of the user the file belonged to when it was on the filesystem.

group​ID

public internal(set) var groupID: Int = 0

The ID of the group the file belonged to when it was on the filesystem.

mode

public internal(set) var mode: FileMode

The permissions and attributes of the file.

modification​Time

public let modificationTime: Int

The last time this file was modified.

Use Int(myDate.timeIntervalSince1970) to set modificationTime from a Date.

inode

public internal(set) var inode: Int? 

The inode (index node) of this file. More information is available on Wikipedia.

link​Name

public internal(set) var linkName: String? 

If this Header describes a symlink, then linkName will contain the name of the linked file.

dev

public internal(set) var dev: (major: Int?, minor: Int?) = (nil, nil) 

The device number of this file when it was on the filesystem.

rDev

public internal(set) var rDev: (major: Int, minor: Int) = (0, 0) 

For block special and character special entries, this field contains the associated device number.

checksum

public internal(set) var checksum: Checksum? 

"...[T]he [checksum] field is set to the sum of all bytes in the file data. This sum is computed [by] treating all bytes as unsigned values and using unsigned arithmetic. Only the least-significant 32 bits of the sum are stored."

size

public internal(set) var size: Int = 0

The size of the file.

This variable is only set when reading in an archive header.

Methods

encode(to:​)

public func encode(to encoder: Encoder) throws  

Operators

==

public static func == (lhs: Header, rhs: Header) -> Bool