TarReader constructor
Creates a tar reader reading from the raw tarStream
.
The disallowTrailingData
parameter can be enabled to assert that the
tarStream
contains exactly one tar archive before ending.
When disallowTrailingData
is disabled (which is the default), the reader
will automatically cancel its stream subscription when moveNext returns
false
.
When it is enabled and a marker indicating the end of an archive is
encountered, moveNext will wait for further events on the stream. If
further data is received, a TarException will be thrown and the
subscription will be cancelled. Otherwise, moveNext effectively waits
for a done event, making a cancellation unnecessary.
Depending on the input stream, cancellations may cause unintended
side-effects. In that case, disallowTrailingData
can be used to ensure
that the stream is only cancelled if it emits an invalid tar file.
The maxSpecialFileSize
parameter can be used to limit the maximum length
of hidden entries in the tar stream. These entries include extended PAX
headers or long names in GNU tar. The content of those entries has to be
buffered in the parser to properly read the following tar entries. To
avoid memory-based denial-of-service attacks, this library limits their
maximum length. Changing the default of 2 KiB is rarely necessary.
Implementation
TarReader(Stream<List<int>> tarStream,
{int maxSpecialFileSize = defaultSpecialLength,
bool disallowTrailingData = false})
: _reader = BlockReader(tarStream),
_checkNoTrailingData = disallowTrailingData,
_maxSpecialFileSize = maxSpecialFileSize;