GzipArchive
public class GzipArchive: Archive
Provides unarchive and archive functions for GZip archives.
-
Unarchives GZip archive.
If data passed is not actually a GZip archive,
GzipErrorwill be thrown.If data in archive is not actually compressed with Deflate algorithm,
DeflateErrorwill be thrown.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.
-
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.If during compression something goes wrong
DeflateErrorwill be thrown. If eitherfileNameorcommentcannot be encoded with ISO Latin-1 encoding, thenGzipError.cannotEncodeISOLatin1will be thrown.Note
This function is specification compliant.
Throws
DeflateErrororGzipError.cannotEncodeISOLatin1depending on the type of of the problem.Declaration
Swift
public static func archive(data: Data, comment: String? = nil, fileName: String? = nil, writeHeaderCRC: Bool = false, isTextFile: Bool = false, osType: GzipHeader.FileSystemType? = nil, modificationTime: Date? = nil) 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.
Return Value
Resulting archive’s data.
View on GitHub
GzipArchive Class Reference