Support multiple concatenated streams #20
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.