Question

I need to decompress a gzip file that contains other files and directories, and save these files separately, it is possible to do this in iOS?

My compressed file has the following structure

file.tar.bz2 
   - db_update.sql 
   - Tmp / 
     - image.png 
     - image2.png 

I found documentation that shows how to do that, but only for when the archive is a single file.

Need to save it in the same archive's structure, is possible?

Was it helpful?

Solution

There are two things you can do here.

  1. Serialized the directory structure using something like tar. For tar, use libarchive.
  2. Switch from using gzip to zip. zip (also called PK zip) can compress a directory structure instead of just a single file. For zip look into minizip.

As @Kevin stated in a comment, you already have a tared file. If you want to go with a .tar.gz format (sometimes given as .tgz), then you only need to decompress the bzip2 part of file.tar.bz2, which will leave you with a file.tar. At that point you can recompress with gzip.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top