SwiftZip Documentation Beta

Class Zip​Mutable​Archive

public final class ZipMutableArchive: ZipArchive

An mutable archive.

%3 ZipMutableArchive ZipMutableArchive ZipArchive ZipArchive ZipMutableArchive->ZipArchive

Nested Types

ZipMutableArchive.MutableEntryCollection

A collection of mutable entries in the archive.

ZipMutableArchive.MutableOpenFlags

A set of flags to be used with ZipMutableArchive.init.

Superclass

ZipArchive

An read-only archive.

Initializers

init(path:​flags:​)

public convenience init(path: String, flags: MutableOpenFlags = []) throws

Opens the zip archive specified by path and sets up an instance, used to manipulate the archive.

Parameters

path String

path to open

flags Mutable​Open​Flags

open flags, defaults to []

init(url:​flags:​)

public convenience init(url: URL, flags: MutableOpenFlags = []) throws

Opens the zip archive specified by URL and sets up an instance, used to manipulate the archive.

Parameters

url URL

URL to open

flags Mutable​Open​Flags

open flags, defaults to []

init(source:​flags:​)

public convenience init(source: ZipSource, flags: MutableOpenFlags = []) throws

Opens a zip archive encapsulated by the ZipSource and sets up an instance, used to manipulate the archive.

Parameters

source Zip​Source

source to open

flags Mutable​Open​Flags

open flags, defaults to []

Properties

unchanged​Entries

var unchangedEntries: EntryCollection

Exposes the original unmodified archive entries as a Swift Collection

mutable​Entries

var mutableEntries: MutableEntryCollection

Exposes mutable archive entries as a Swift Collection

Methods

close()

public func close() throws

Writes any changes made to archive to disk. If archive contains no files, the file is completely removed (no empty archive is written). If successful, archive is invalidated, otherwise archive is left unchanged.

set​Comment(_:​)

public func setComment(_ comment: String?) throws

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

Parameters

comment String?

new comment value

get​Mutable​Entry(index:​)

public func getMutableEntry(index: Int) throws -> ZipMutableEntry

Retrieves archive entry by index using the original data from the zip archive, ignoring any changes made to the file.

Parameters

index Int

index of entry to retrieve

add​Directory(name:​)

@discardableResult public func addDirectory(name: String) throws -> ZipMutableEntry

Adds a directory to a zip archive.

Parameters

name String

the directory's name in the zip archive

add​File(name:​source:​flags:​)

@discardableResult public func addFile(name: String, source: ZipSource, flags: AddFileFlags = []) throws -> ZipMutableEntry

Adds a file to a zip archive.

Parameters

name String

the file's name in the zip archive

source Zip​Source

the data of the file

flags Add​File​Flags

operation flags, defaults to []

unchange​Globals()

public func unchangeGlobals() throws

Revert all global changes to the archive. This reverts changes to the archive comment and global flags.

unchange​All()

public func unchangeAll() throws

All changes to files and global information in archive are reverted.