TarReader

TarReader

TarReader provides methods for listing and reading the contents of tar files. This is used by the bag validator to validate tarred bags without having to untar them first.

Both TarReader and FileSystemReader implement a common interface and emit a common set of events to provide the bag validator with a uniform interface for reading bags packaged in different formats.

See the list() and read() functions below for information about the events they emit.

Constructor

new TarReader(pathToTarFile)

Creates a new TarReader.

Parameters:
Name Type Description
pathToTarFile string

This should be the absolute path to the tar file you want to read.

Source:

Members

byteCount :number

byteCount keeps track of the total number of bytes in all files beneath the speficied directory. This value is valid only during list operations, not during read().

Source:

dirCount :number

dirCount is the number of directories encountered during a read() or list() operation.

Source:

fileCount :number

fileCount is the number of files encountered during a read() or list() operation.

Source:

pathToTarFile :string

pathToTarFile is the absolute path to the tar file that this iterator will read.

Source:

Methods

(static) description() → {PluginDefinition}

Returns a PluginDefinition object describing this plugin.

Source:

list()

The list() method returns information about the contents files and directories inside a tar file. Unlike read(), it does not return a readable stream for any of the files it encounters.

list() emits the events "entry", "error" and "end".

Source:

read()

The read() method reads the contents of the tar file. It emits the events "entry", "error" and "end".

The read() method returns the same information as the list() method, plus a readable stream from which you can extract the contents of individual tar files.

Note that read() will not advance to the next entry until you've read the entire stream returned returned by the "entry" event.

Source:

Events

end

This indicates that the iterator has passed the last entry in the tar file and there's nothing left to read.

Source:

entry :object

The entry event of the read() method includes both info about the tar file (from the header) and a ReadStream object that allows you to read the contents of the entry, if it's a file. Note that you MUST read the stream to the end before TarReader.read() will move to the next tar entry.

Properties:
Name Type Description
relPath string

The relative path (within the tar file) of the entry.

stream ReadStream

A stream from which you can read the contents of the entry.

fileStat FileStat

An object containing a subset info similar to the fs.Stats object, describing the file's size and other attributes.

Source:

entry :object

The entry event of the list() method returns info about the tar entry, but no reader to read the contents of the entry.

Properties:
Name Type Description
relPath string

The relative path (within the tar file) of the entry.

fileStat FileStat

An object containing a subset info similar to the fs.Stats object, describing the file's size and other attributes.

Source:

error :Error

Indicates something went wrong while reading the tarfile.

Source: