unbzip2-stream stops decoding as soon as it encounters an EOS marker, but bzip2 transparently supports concatenated streams like so:
cat <(echo -n a | bzip2) <(echo b | bzip2) | bunzip2
The example file in #19 is such a case of concatenation.
To support this feature the current implementation needs to be more precise in consuming the correct number of bits/bytes up until the first stream ends, so that decoding for following bzip2 streams picks up at the right position again. If the input stream doesn't end after the first bzip2 stream, the decoder will now continue and expect additional bzip2 streams until the input stream ends.
As an intermediate step, this PR also validates the stream checksum that directly follows each EOS marker, to validate that all blocks were present and in the right order.
Fixes #19
unbzip2-stream stops decoding as soon as it encounters an EOS marker, but bzip2 transparently supports concatenated streams like so:
cat <(echo -n a | bzip2) <(echo b | bzip2) | bunzip2
The example file in #19 is such a case of concatenation. To support this feature the current implementation needs to be more precise in consuming the correct number of bits/bytes up until the first stream ends, so that decoding for following bzip2 streams picks up at the right position again. If the input stream doesn't end after the first bzip2 stream, the decoder will now continue and expect additional bzip2 streams until the input stream ends. As an intermediate step, this PR also validates the stream checksum that directly follows each EOS marker, to validate that all blocks were present and in the right order.