Class
ZipMutableArchive
public final class ZipMutableArchive: ZipArchive
An mutable archive.
Relationships
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
Name | Type | Description |
---|---|---|
path | String |
path to open |
flags | MutableOpenFlags |
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
Name | Type | Description |
---|---|---|
url | URL |
URL to open |
flags | MutableOpenFlags |
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
Name | Type | Description |
---|---|---|
source | ZipSource |
source to open |
flags | MutableOpenFlags |
open flags, defaults to |
Properties
unchangedEntries
var unchangedEntries: EntryCollection
Exposes the original unmodified archive entries as a Swift Collection
mutableEntries
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.
setComment(_:)
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
Name | Type | Description |
---|---|---|
comment | String? |
new comment value |
getMutableEntry(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
Name | Type | Description |
---|---|---|
index | Int |
index of entry to retrieve |
addDirectory(name:)
@discardableResult public func addDirectory(name: String) throws -> ZipMutableEntry
Adds a directory to a zip archive.
Parameters
Name | Type | Description |
---|---|---|
name | String |
the directory's name in the zip archive |
addFile(name:source:flags:)
@discardableResult public func addFile(name: String, source: ZipSource, flags: AddFileFlags = []) throws -> ZipMutableEntry
Adds a file to a zip archive.
Parameters
Name | Type | Description |
---|---|---|
name | String |
the file's name in the zip archive |
source | ZipSource |
the data of the file |
flags | AddFileFlags |
operation flags, defaults to |
unchangeGlobals()
public func unchangeGlobals() throws
Revert all global changes to the archive. This reverts changes to the archive comment and global flags.
unchangeAll()
public func unchangeAll() throws
All changes to files and global information in archive are reverted.