Option to disable "raw" libarchive format
I'd like to use compress-tools-rs in a situation where I want to treat archive and non-archive files differently; enabling the "raw" format makes it effectively impossible to distinguish archives from non-archives and/or corrupt archives.
I didn't understand the use case you're trying to cover. If you want to check if the file is an archive or not it might be done using the file header for example.
The use-case is a tool which performs file analysis and searches on a directory, including support for traversing archive files found within said directory. The question I'm trying to answer, as such, is "is libarchive capable of parsing a given, otherwise unknown, file as an archive?".
Checking if a file is a valid archive with another tool is not sufficient, as (a) libarchive's scope of supported can depend on version and compile flags, (b) I would need to repeat myself by writing checks for every format currently supported by libarchive regardless.
Generally speaking, if not supported, it will report an error. Isn't this enough?
It will not. The "raw" format enables reading any file, even one which is not an archive, as an archive containing a single file, "data". Quoting from the libarchive documentation, emphasis mine:
archive_read_support_format_raw() The “raw” format handler allows libarchive to be used to read arbitrary data. It treats any data stream as an archive with a single entry. The pathname of this entry is “data”; all other entry fields are unset. This is not enabled by archive_read_support_format_all() in order to avoid erroneous handling of damaged archives.
Ok so what is your proposal? Please open a draft PR proposing what you'd like to be done so we can understand it better.
Have you thought about the API you'd like to have?
Sorry. I've started looking into it, but I've been working on other projects since, and I have no ETA to coming back to this :(