GzipArchive
public class GzipArchive : Archive
Provides unarchive and archive functions for GZip archives.
-
Represents the member of a multi-member GZip archive.
See moreDeclaration
Swift
public struct Member -
Unarchives GZip archive.
Note
This function is specification compliant.
Throws
DeflateErrororGzipErrordepending on the type of the problem. It may indicate that either archive is damaged or it might not be archived with GZip or compressed with Deflate at all.Declaration
Swift
public static func unarchive(archive data: Data) throws -> DataParameters
archiveData archived with GZip.
Return Value
Unarchived data.
-
Unarchives multi-member GZip archive. Multi-member GZip archives are essentially several GZip archives following each other in a single file.
Throws
DeflateErrororGzipErrordepending on the type of the problem. It may indicate that one of the members of archive is damaged or it might not be archived with GZip or compressed with Deflate at all.Declaration
Swift
public static func multiUnarchive(archive data: Data) throws -> [Member]Parameters
archiveGZip archive with one or more members.
Return Value
Unarchived data.
-
Archives
datainto GZip archive, using various specified options. Data will be also compressed with Deflate algorithm. It will be also specified in archive’s header that the compressor used the slowest Deflate algorithm.Note
This function is specification compliant.
Throws
GzipError.cannotEncodeISOLatin1if a file name or a comment cannot be encoded with ISO-Latin-1 encoding or if the total sum of the binary content length of all extra fields plus 4 for each field exceedsUInt16.max.Declaration
Swift
public static func archive(data: Data, comment: String? = nil, fileName: String? = nil, writeHeaderCRC: Bool = false, isTextFile: Bool = false, osType: FileSystemType? = nil, modificationTime: Date? = nil, extraFields: [GzipHeader.ExtraField] = []) throws -> DataParameters
dataData to compress and archive.
commentAdditional comment, which will be stored as a separate field in archive.
fileNameName of the file which will be archived.
writeHeaderCRCSet to true, if you want to store consistency check for archive’s header.
isTextFileSet to true, if the file which will be archived is text file or ASCII-file.
osTypeType of the system on which this archive will be created.
modificationTimeLast time the file was modified.
extraFieldsAny extra fields. Note that no extra field is allowed to have second byte of the extra field (subfield) ID equal to zero. In addition, the length of a field’s binary content must be less than
UInt16.max, while the total sum of the binary content length of all extra fields plus 4 for each field must also not exceedUInt16.max. See GZip format specification for more details.Return Value
Resulting archive’s data.
View on GitHub
GzipArchive Class Reference