SevenZipSharp icon indicating copy to clipboard operation
SevenZipSharp copied to clipboard

Does not work with .tar.gz and .tar.bz2?

Open ravibpatel opened this issue 6 years ago • 5 comments

Thanks for the great library.

I am having some problems with it. I tried to read .tar.gz and .tar.bz2 files but it comes with wrong data. It shows only 1 file in the archive "[no name]".

You can download the example file from here.

I also tried the same file with SevenZipLib and it works fine.

ravibpatel avatar Feb 27 '19 08:02 ravibpatel

The likely cause is due to what a tar.gz and tar.bz2 file actually is - the files are first packaged in a tar file (that has no file compression) and then that tar file is compressed using either gz or bz2.

I'll look into a solution for this soon-ish, but the "[no name]" file is likely the tar file that is now extracted - so you'd need to extract that file as well to get the actual files you're looking for.

squid-box avatar Feb 27 '19 10:02 squid-box

I found one likely solution. I looked at the SevenZipLIb source code and find out it does exactly as you told. It detects if it has a sub-archive. If it is found then it extracts the sub-archive into a temp folder and read archive entries.

Look at line no. 1207. It calls the OpenSubArchive method which is responsible for reading tar archive inside gz archive.

Is there any way to detect sub-archive in SevenZipSharp?

ravibpatel avatar Feb 27 '19 18:02 ravibpatel

So I'm a little hesitant on this issue, because on one hand I understand your view of this - usually you want to get the directly to the sub-archive of the tar.gz file.

But on the other hand, extracting a .gz file should provide whatever contents as a result, even if that happens to be a .tar file - and that is the same behavior I'm seeing with 7z (if I open a .tar.gz file, it shows me the .tar file).

I'll look into if it could be smartly added as an option to extraction.

squid-box avatar Mar 03 '19 01:03 squid-box

7zip works that way but other applications like WinRAR and Directory Opus extracts the tar file as a folder when you try to extract the .gz file and I think it will be more user-friendly that way.

ravibpatel avatar Mar 03 '19 05:03 ravibpatel

I think by definition, a GZip can(should) only have one tar file. See the years of requests to add this functionality to 7zip https://sourceforge.net/p/sevenzip/discussion/45797/thread/5eb1b8d5/?page=0. It would definitely be a nice to have. It's the reason I came looking for this lib - to see if it supported expanding a gz/tar in one operation.

sandscap-sc avatar Jul 07 '20 23:07 sandscap-sc