TarContainer

public class TarContainer : Container

Provides functions for work with TAR containers.

  • Represents the “format” of a TAR container: a minimal set of extensions to basic TAR format required to successfully read a particular container.

    See more

    Declaration

    Swift

    public enum Format
  • Processes TAR container and returns its “format”: a minimal set of extensions to basic TAR format required to successfully read this container.

    Throws

    TarError, which may indicate that either container is damaged or it might not be TAR container at all.

    Declaration

    Swift

    public static func formatOf(container data: Data) throws -> Format

    Parameters

    container

    TAR container’s data.

  • Creates a new TAR container with entries as its content and generates its Data.

    See also

    TarEntryInfo properties documenation to see how their values are connected with the specific TAR format used during container creation.

    Declaration

    Swift

    public static func create(from entries: [TarEntry]) -> Data

    Parameters

    entries

    TAR entries to store in the container.

  • Creates a new TAR container with entries as its content and generates its Data using the specified format.

    This function forces the usage of the format, meaning that certain properties of the entries may be missing from the resulting container data if the chosen format does not support corresponding features. For example, relatively long names (and linknames) will be truncated if the .ustar or .prePosix format is specified.

    It is highly recommended to use the TarContainer.create(from:) function (or use the .pax format) to ensure the best representation of the entries in the output. Other (non-PAX) formats should only be used if you have a specific need for them and you understand limitations of those formats.

    See also

    TarEntryInfo properties documenation to see how their values are connected with the specific TAR format used during container creation.

    Declaration

    Swift

    public static func create(from entries: [TarEntry], force format: TarContainer.Format) -> Data

    Parameters

    entries

    TAR entries to store in the container.

    force

    Force the usage of the specified format.

  • Processes TAR container and returns an array of TarEntry with information and data for all entries.

    Important

    The order of entries is defined by TAR container and, particularly, by the creator of a given TAR container. It is likely that directories will be encountered earlier than files stored in those directories, but no particular order is guaranteed.

    Throws

    TarError, which may indicate that either container is damaged or it might not be TAR container at all.

    Declaration

    Swift

    public static func open(container data: Data) throws -> [TarEntry]

    Parameters

    container

    TAR container’s data.

    Return Value

    Array of TarEntry.

  • Processes TAR container and returns an array of TarEntryInfo with information about entries in this container.

    Important

    The order of entries is defined by TAR container and, particularly, by the creator of a given TAR container. It is likely that directories will be encountered earlier than files stored in those directories, but no particular order is guaranteed.

    Throws

    TarError, which may indicate that either container is damaged or it might not be TAR container at all.

    Declaration

    Swift

    public static func info(container data: Data) throws -> [TarEntryInfo]

    Parameters

    container

    TAR container’s data.

    Return Value

    Array of TarEntryInfo.