SwiftZip Documentation Beta

Class Zip​Entry

public class ZipEntry

A read-only accessor for an entry in the archive.

%3 ZipEntry ZipEntry ZipMutableEntry ZipMutableEntry ZipMutableEntry->ZipEntry

Nested Types

ZipEntry.ExternalAttributes

A platform-specific external attributes of the archive entry.

ZipEntry.ExtraFieldFlags

A lookup flag for extra fields of the archive entry.

ZipEntry.OpenFlags

A set of flags to be used with ZipEntry.open.

Subclasses

ZipMutableEntry

A read-write accessor for an entry in the archive.

Methods

get​Name(decoding​Strategy:​)

public final func getName(decodingStrategy: ZipStringDecodingStrategy = .guess) throws -> String

Returns the name of the file in the archive.

Parameters

decoding​Strategy Zip​String​Decoding​Strategy

string decoding strategy, defaults to .guess

get​Raw​Name()

public final func getRawName() throws -> Data

Returns the unmodified name of the as it is in the ZIP archive

get​External​Attributes()

public final func getExternalAttributes() throws -> ExternalAttributes

Returns the operating system and external attributes for the file in the zip archive. The external attributes usually contain the operating system-specific file permissions.

stat()

public final func stat() throws -> ZipStat

Obtains information about the file in archive.

get​Extra​Fields​Count(flags:​)

public final func getExtraFieldsCount(flags: ExtraFieldFlags = [.local, .central]) throws -> Int

Counts the extra fields for the file in the zip archive.

Parameters

flags Extra​Field​Flags

field lookup flags, defaults to [.local, .central]

get​Extra​Fields​Count(id:​flags:​)

public final func getExtraFieldsCount(id: UInt16, flags: ExtraFieldFlags = [.local, .central]) throws -> Int

Counts the extra fields with ID (two-byte signature) id for the file in the zip archive.

Parameters

id UInt16

field ID (two-byte signature) filter

flags Extra​Field​Flags

field lookup flags, defaults to [.local, .central]

get​Extra​Field(index:​flags:​)

public final func getExtraField(index: Int, flags: ExtraFieldFlags = [.local, .central]) throws -> (id: UInt16, data: Data)

Returns the extra field with index index for the file in the zip archive.

Parameters

index Int

field index to retrieve

flags Extra​Field​Flags

field lookup flags, defaults to [.local, .central]

get​Extra​Field(id:​index:​flags:​)

public final func getExtraField(id: UInt16, index: Int, flags: ExtraFieldFlags = [.local, .central]) throws -> Data

Returns the index-s extra field with a specified field ID for the file in the zip archive.

Parameters

id UInt16

field ID (two-byte signature) filter

index Int

field index to retrieve

flags Extra​Field​Flags

field lookup flags, defaults to [.local, .central]

get​Comment(decoding​Strategy:​)

public final func getComment(decodingStrategy: ZipStringDecodingStrategy = .guess) throws -> String

Returns the comment for the file in the zip archive.

Parameters

decoding​Strategy Zip​String​Decoding​Strategy

string decoding strategy, defaults to .guess

get​Raw​Comment()

public final func getRawComment() throws -> Data

Returns the unmodified comment for the file as it is in the ZIP archive.

open(flags:​password:​)

public final func open(flags: OpenFlags = [], password: String? = nil) throws -> ZipEntryReader

Opens the file using the password given in the password argument.

Parameters

flags Open​Flags

open flags, defaults to []

password String?

optional password to decrypt the entry

data(flags:​password:​)

public func data(flags: OpenFlags = [], password: String? = nil) throws -> Data

Retrieves entry contents as Data instance.

Parameters

flags Open​Flags

open flags, defaults to []

password String?

optional password to decrypt the entry

save(to:​flags:​password:​progress​Handler:​)

@discardableResult public func save(to url: URL, flags: OpenFlags = [], password: String? = nil, progressHandler: ((Double) -> Bool)? = nil) throws -> Bool

Saves entry contents to a file.

Parameters

url URL

destination file URL

flags Open​Flags

open flags, defaults to []

password String?

optional password to decrypt the entry

progress​Handler ((Double) -> Bool)?

progress handler callback