TAR

  • Provides functions for work with TAR containers.

    See more

    Declaration

    Swift

    public class TarContainer : Container
  • A type that allows to iteratively read TAR entries from a container provided by a FileHandle.

    The TarReader may be helpful in reducing the peak memory usage on certain platforms. However, to achieve this either the TarReader.process(_:) function should be used or both the call to TarReader.read() and the processing of the returned entry should be wrapped inside the autoreleasepool. Since the autoreleasepool is available only on Darwin platforms, the memory reducing effect may be not as significant on non-Darwin platforms (such as Linux or Windows).

    The following code demonstrates an example usage of the TarReader:

       let handle: FileHandle = ...
       let reader = TarReader(fileHandle: handle)
       try reader.process { ... }
       ...
       try handle.close()
    

    Note that closing the FileHandle remains the responsibility of the caller.

    Important

    Due to the API availability limitations of Foundation’s FileHandle, on certain platforms errors in FileHandle operations may result in unrecoverable runtime failures due to unhandled Objective-C exceptions (which are impossible to correctly handle in Swift code). As such, it is not recommended to use TarReader on those platforms. The following platforms are unaffected by this issue: macOS 10.15.4+, iOS 13.4+, watchOS 6.2+, tvOS 13.4+, and any other platforms without Objective-C runtime.
    See more

    Declaration

    Swift

    public struct TarReader
  • A type that allows to iteratively create TAR containers with the output being written into a FileHandle.

    The TarWriter may be helpful in reducing the peak memory usage on certain platforms. However, to achieve this both the creation of TAR entries and the calls to TarWriter should be wrapped inside the autoreleasepool. Since the autoreleasepool is available only on Darwin platforms, the memory reducing effect may be not as significant on non-Darwin platforms (such as Linux or Windows).

    The following code demonstrates an example usage of the TarWriter:

       let handle: FileHandle = ...
       let writer = TarWriter(fileHandle: handle)
       try autoreleasepool {
           let entry: TarEntry = ...
           try writer.append(entry)
       }
       try writer.finalize()
       try handle.close()
    

    Note that TarWriter.finalize() must be called after finishing appending entries to the container. In addition, closing the FileHandle remains the responsibility of the caller.

    Important

    Due to the API availability limitations of Foundation’s FileHandle, on certain platforms errors in FileHandle operations may result in unrecoverable runtime failures due to unhandled Objective-C exceptions (which are impossible to correctly handle in Swift code). As such, it is not recommended to use TarWriter on those platforms. The following platforms are unaffected by this issue: macOS 10.15.4+, iOS 13.4+, watchOS 6.2+, tvOS 13.4+, and any other platforms without Objective-C runtime.
    See more

    Declaration

    Swift

    public struct TarWriter
  • Represents an entry from the TAR container.

    See more

    Declaration

    Swift

    public struct TarEntry : ContainerEntry
  • Provides access to information about an entry from the TAR container.

    See more

    Declaration

    Swift

    public struct TarEntryInfo : ContainerEntryInfo