Search code examples
c++libarchive

libarchive how to read concatenated tar


I want to read a tar file that was made by concatenating multiple .tar.gz files using cat one.tar.gz two.tar.gz .... > combined.tar.gz using libarchive.

I'm able to read files for the first tar file fine using a while(;;) r = archive_read_next_header(a, &entry);, but as soon as finishes reading it, I get a Closing file Segmentation fault (core dumped)

How do I let libarchive move to reading the next tar file?


Solution

  • Turns out the library supports this. Only need to set the read_concatenated_archives option set.

    archive_read_set_options(a, "read_concatenated_archives")

    see here for an example.