BZip2

public class BZip2 : DecompressionAlgorithm
extension BZip2: CompressionAlgorithm

Provides functions for compression and decompression for BZip2 algorithm.

  • Decompresses data using BZip2 algortihm.

    Throws

    BZip2Error if unexpected byte (bit) sequence was encountered in data. It may indicate that either data is damaged or it might not be compressed with BZip2 at all.

    Declaration

    Swift

    public static func decompress(data: Data) throws -> Data

    Parameters

    data

    Data compressed with BZip2.

    Return Value

    Decompressed data.

  • Decompresses one or more concatenated BZip2 archives found in data.

    Throws

    BZip2Error if an unexpected byte (bit) sequence was encountered or a checksum mismatch is detected for any archive. It may indicate that the input is damaged or it might not be compressed with BZip2 at all. If BZip2Error.wrongCRC is thrown, its associated value contains only the bytes decompressed for the archive that failed the checksum.

    Declaration

    Swift

    public static func multiDecompress(data: Data) throws -> [Data]

    Parameters

    data

    Data that may contain one or more concatenated BZip2 archives.

    Return Value

    An array of decompressed data, one element per archive, in the same order as they appear in the input.

  • Represents the size of the blocks in which data is split during BZip2 compression.

    See more

    Declaration

    Swift

    public enum BlockSize : Int
  • Compresses data with BZip2 algortihm.

    Note

    Input data will be split into blocks of size 100 KB. Use BZip2.compress(data:blockSize:) function to specify the size of a block.

    Declaration

    Swift

    public static func compress(data: Data) -> Data

    Parameters

    data

    Data to compress.

  • Compresses data with BZip2 algortihm, splitting data into blocks of specified blockSize.

    Declaration

    Swift

    public static func compress(data: Data, blockSize: BlockSize) -> Data

    Parameters

    data

    Data to compress.

    blockSize

    Size of blocks in which data will be split.