CPIOArchiveKit Documentation

Structure File​Mode

public struct FileMode: RawRepresentable, Equatable  

A FileMode contains a file's permissions and file type.

%27 FileMode FileMode RawRepresentable RawRepresentable FileMode->RawRepresentable Equatable Equatable FileMode->Equatable

Conforms To

Equatable
RawRepresentable

Nested Type Aliases

Raw​Value

public typealias RawValue = UInt32

Initializers

init(raw​Value:​)

public init(rawValue: UInt32)  

init(_:​modes:​)

public init(_ permissions: UInt32, modes: Set<FileType> = [.regular])  

Creates a FileMode.

Parameters

permissions UInt32

The UNIX file permissions.

modes Set<File​Type>

FileTypes that describe the file. For example, if you wanted to specify that this FileMode describes a directory, you would add the .dir type. If it is also a symlink, you would add the .symlink type.

Properties

raw​Value

public var rawValue: UInt32

permissions

public var permissions: UInt32  

The UNIX permissions of this FileMode.

type

public var type: FileType?  

The FileType of self.

switch header.mode.type {
	case .directory: // Directory.
	case .regular: // Regular File.
	case .symlink: // Symbolic Link.
	...
	case nil:
		// unknown type.
}

raw​Type

public var rawType: UInt32  

The file type bits in self.rawValue, or, in other words, the raw version of self.type.

Methods

`is`(_:​)

public func `is`(_ type: FileType) -> Bool  

Check whether this FileMode is type.

if myHeader.mode.is(.directory) {
    // myHeader describes a directory.
} else if myHeader.mode.is(.file) {
    // myHeader describes a file.
} else if ...