SwiftZip Documentation Beta

Class Zip​Mutable​Entry

public final class ZipMutableEntry: ZipEntry

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

%3 ZipMutableEntry ZipMutableEntry ZipEntry ZipEntry ZipMutableEntry->ZipEntry

Superclass

ZipEntry

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

Methods

set​External​Attributes(operating​System:​attributes:​)

public func setExternalAttributes(operatingSystem: ExternalAttributes.OperatingSystem, attributes: UInt32) throws

Sets the operating system and external attributes for the file in the zip archive.

Parameters

operating​System External​Attributes.​Operating​System

operating system value

attributes UInt32

external attributes to set

set​External​Attributes(operating​System:​posix​Attributes:​)

public func setExternalAttributes(operatingSystem: ExternalAttributes.OperatingSystem = .unix, posixAttributes: mode_t) throws

Sets the operating system and POSIX attributes to be set as external attributes for the file in the zip archive.

Parameters

operating​System External​Attributes.​Operating​System

operating system value, defaults to .unix

posix​Attributes mode_t

POSIX attributes to be set

set​Extra​Field(id:​index:​data:​flags:​)

public func setExtraField(id: UInt16, index: Int?, data: Data, flags: ExtraFieldFlags) throws

Sets the extra field with ID (two-byte signature) id and index index for the file in the zip archive. The extra field's data will be set to data. If a new entry shall be appended, set index to nil.

Please note that the extra field IDs 0x0001 (ZIP64 extension), 0x6375 (Infozip UTF-8 comment), and 0x7075 (Infozip UTF-8 file name) can not be set using setExtraField since they are set by libzip(3) automatically when needed.

Parameters

id UInt16

field ID (two-byte signature) filter

index Int?

field index to set

data Data

new field data

flags Extra​Field​Flags

field lookup flags

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

public func deleteExtraField(index: Int?, flags: ExtraFieldFlags) throws

Deletes the extra field with index index for the file in the zip archive. If index is nil, then all extra fields will be deleted.

Parameters

id

field ID (two-byte signature) filter

index Int?

field index to delete

flags Extra​Field​Flags

field lookup flags

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

public func deleteExtraField(id: UInt16, index: Int?, flags: ExtraFieldFlags) throws

Deletes the index-s extra field with a specified field ID for the file in the zip archive. If index is nil, then all extra fields with the specified ID will be deleted.

Parameters

id UInt16

field ID (two-byte signature) filter

index Int?

field index to delete

flags Extra​Field​Flags

field lookup flags

set​Comment(_:​)

public func setComment(_ comment: String?) throws

Sets the comment for the file in the zip archive.If comment is set to nil, the comment is deleted from the archive.

Parameters

comment String?

new comment string

set​Modified​Date(_:​)

public func setModifiedDate(_ date: Date) throws

Sets the last modification time (mtime) for the file in the zip archive to date.

Parameters

date Date

new file modification time

set​Compression(method:​flags:​)

public func setCompression(method: ZipStat.CompressionMethod = .default, flags: ZipStat.CompressionFlags = .default) throws

Sets the compression method for the file in the zip archive.

Parameters

method Zip​Stat.​Compression​Method

compression method to set

flags Zip​Stat.​Compression​Flags

compression method specific flags

set​Encryption(method:​password:​)

public func setEncryption(method: ZipStat.EncryptionMethod, password: String? = nil) throws

Sets the encryption method and password for the file in the zip archive. If password is nil, the default password provided by ZipArchive.setDefaultPassword is used.

Parameters

method Zip​Stat.​Encryption​Method

encryption method to set

password String?

encryption password

delete()

public func delete() throws

Marks the file the archive as deleted.

unchange()

public func unchange() throws

Changes to the file are reverted.