SevenZipSharp
SevenZipSharp copied to clipboard
Does not work with .tar.gz and .tar.bz2?
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.
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.
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?
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.
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.
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.