Also improve error reporting for `--format` with malformed or
unsupported extensions
This commit is very messy, as it also does an refac in the project,
which should ideally be in a separated commit
Fixes#687.
If "-" is passed as a filename, decompress data from stdin.
Currently `--format` must be passed as well, but as a next step,
we could try to infer the format from magic numbers.
As stdin is not connected to the terminal, we cannot prompt for Y/N
when warning about decompression in memory, for e.g. zip. Just default
to No, and require passing "-y" in these cases.
For zip, we have to buffer the whole stream in memory to seek into it,
just as we do with a chained decoder like `.zip.bz`.
The rar format requires an actual file (not an `impl Read`), so
we write a temp file that it can decode.
When decoding a single-file archive (e.g. file.bz), the output filename
is just `-`, since we don't know the original filename. I had to add
a bit of a hack to the tests to work around this. Another option
would be to interpret "-d" as a destination filename in this case.
When decoding a multi-file archive, I decided to unpack directly into
the destination directory, as this seemed like a better experience than
adding a top-level "-" folder inside the destination.
The single_empty_file test was writing random content to the file,
whereas the single_file test was writing an empty file.
Only the latter tested different levels, so I figured that test
was the one that should be using actual file content.
Our GitHub Actions CI was failing because the ARMv7 systems use QEMU
which consumes more memory than usual, by decreasing the memory usage,
we expect to make it all work again.
* Actually fill dummy files with random data
* Switch rem logic to more obvious random range
* Test all available formats
* Enable accessibility mode in tests to drastically reduce runtime