Class
ZipEntry
public class ZipEntry
A read-only accessor for an entry in the archive.
Relationships
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
getName(decodingStrategy:)
public final func getName(decodingStrategy: ZipStringDecodingStrategy = .guess) throws -> String
Returns the name of the file in the archive.
Parameters
Name | Type | Description |
---|---|---|
decodingStrategy | ZipStringDecodingStrategy |
string decoding strategy, defaults to |
getRawName()
public final func getRawName() throws -> Data
Returns the unmodified name of the as it is in the ZIP archive
getExternalAttributes()
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.
getExtraFieldsCount(flags:)
public final func getExtraFieldsCount(flags: ExtraFieldFlags = [.local, .central]) throws -> Int
Counts the extra fields for the file in the zip archive.
Parameters
Name | Type | Description |
---|---|---|
flags | ExtraFieldFlags |
field lookup flags, defaults to |
getExtraFieldsCount(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
Name | Type | Description |
---|---|---|
id | UInt16 |
field ID (two-byte signature) filter |
flags | ExtraFieldFlags |
field lookup flags, defaults to |
getExtraField(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
Name | Type | Description |
---|---|---|
index | Int |
field index to retrieve |
flags | ExtraFieldFlags |
field lookup flags, defaults to |
getExtraField(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
Name | Type | Description |
---|---|---|
id | UInt16 |
field ID (two-byte signature) filter |
index | Int |
field index to retrieve |
flags | ExtraFieldFlags |
field lookup flags, defaults to |
getComment(decodingStrategy:)
public final func getComment(decodingStrategy: ZipStringDecodingStrategy = .guess) throws -> String
Returns the comment for the file in the zip archive.
Parameters
Name | Type | Description |
---|---|---|
decodingStrategy | ZipStringDecodingStrategy |
string decoding strategy, defaults to |
getRawComment()
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
Name | Type | Description |
---|---|---|
flags | OpenFlags |
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
Name | Type | Description |
---|---|---|
flags | OpenFlags |
open flags, defaults to |
password | String? |
optional password to decrypt the entry |
save(to:flags:password:progressHandler:)
@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
Name | Type | Description |
---|---|---|
url | URL |
destination file URL |
flags | OpenFlags |
open flags, defaults to |
password | String? |
optional password to decrypt the entry |
progressHandler | ((Double) -> Bool)? |
progress handler callback |