Allow to read from input streams for all elements of a tar archive
Author KlausC
0 Stars
Updated Last
2 Years Ago
Started In
January 2020


Build Status Codecov

The TarIterators package can read from individual elements of POSIX TAR archives ("tarballs") as specified in POSIX 1003.1-2001.

API & Usage

The public API of TarIterators includes only standard functions and one type:

  • TarIterator — struct representing a file stream opened for reading a TAR file, may be restricted by predicates

  • iterate — deliver pairs of Tar.header and BoundedInputStream for each element

  • close - close wrapped stream

  • open - deliver BoundedInputStream for the next element of tar file or process all elements in a loop

  • seekstart - reset input to start

Usage Example

    using TarIterators

    ti = TarIterator("/tmp/AB.tar", :file)
    for (h, io) in ti
        x = read(io, String)

    # reset to start

    # or equivalently
    open(ti) do h, io
        x = read(io, String)

    using CodecZlib
    cio = GzipDecompressorStream(open("/tmp/AB.tar.gz"))

    # process first file named "B"
    io = open(TarIterator(cio, "B", close_stream=true))
    x = read(io, 10)
    close(io) # cio is closed implicitly

Used By Packages

No packages found.