Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extraction multi file zip archive -> failes #20

Open
muffmolch opened this issue Mar 8, 2018 · 8 comments
Open

extraction multi file zip archive -> failes #20

muffmolch opened this issue Mar 8, 2018 · 8 comments

Comments

@muffmolch
Copy link

muffmolch commented Mar 8, 2018

As it seems SevenZipExtractor cannot handle multi file archives, can it?

File.7z.001
File.7z.002
File.7z.003
using(ArchiveFile archiveFile = new ArchiveFile("File.7z.001")) {
   archiveFile.Extract(extractPath); // extract all
}

-> exception

@adoconnection
Copy link
Owner

Interesting.

Every entry appears to have at least two properties, indicating the entry is split: IsSplitBeforeand IsSplitAfter (update to 1.0.12 to see these properties)
If, for example, IsSplitBefore = true, this means the beginning of entry is in previous parts of archive.

simple entry.Extract(); is not working. My quick guess – to extract one entry one have to locate all parts first and merge all streams together in a single file. I didnt see any quick way of doing so in SevenZip interface.

Maybe someone can help?

@adoconnection
Copy link
Owner

List<string> files = new List<string>()
{
    @"H:\SkyTest.part1.rar",
    @"H:\SkyTest.part2.rar",
    @"H:\SkyTest.part3.rar",
    @"H:\SkyTest.part4.rar",
    @"H:\SkyTest.part5.rar",
};

foreach (string file in files)
{
    using (ArchiveFile archiveFile = new ArchiveFile(file))
    {
        Console.WriteLine(Path.GetFileName(file).ToUpper());

        foreach (Entry entry in archiveFile.Entries)
        {
            Console.WriteLine(entry.FileName +  " - " + entry.IsSplitBefore + " - " + entry.IsSplitAfter);
        }
    }
}

@AyratShigapov
Copy link

image

Добрый день.
Для открытия многофайлового архива достаточно открыть первый архив?

@fgimian
Copy link

fgimian commented Aug 20, 2022

Hey there, looks like https://github.com/squid-box/SevenZipSharp implements multi-part archive support by creating an appended stream of all files. See the MultiStreamWrapper class here and InMultiStreamWrapper class here.

I'll be attempting this approach with SevenZipExtractor using the public ArchiveFile(Stream archiveStream, SevenZipFormat? format = null, string libraryFilePath = null) constructor to see if it works now.

Edit: I had no luck getting this working myself.

Cheers
Fotis

@adoconnection
Copy link
Owner

Is SevenZipSharp itself is capable of extracting multipart archives? If yes then its worth to dive in.

@fgimian
Copy link

fgimian commented Aug 20, 2022

Is SevenZipSharp itself is capable of extracting multipart archives? If yes then its worth to dive in.

I'll test it out thoroughly tonight and let you know mate, thanks so so much for your amazing library. 😊

@fgimian
Copy link

fgimian commented Aug 20, 2022

Okies, I've had some time to test this tonight with Squid-Box.SevenZipSharp and a multipart RAR file which I created from the PowerShell installer.

PS C:\Users\Fots\source\MultiTest.SevenZipSharp> dir C:\Users\Fots\Downloads\

    Directory: C:\Users\Fots\Downloads

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          19/08/2022  3:11 PM      106954752 PowerShell-7.2.6-win-x64.msi
-a---          20/08/2022  2:16 PM       26214400 PowerShell-7.2.6-win-x64.part1.rar
-a---          20/08/2022  2:16 PM       26214400 PowerShell-7.2.6-win-x64.part2.rar
-a---          20/08/2022  2:16 PM       26214400 PowerShell-7.2.6-win-x64.part3.rar
-a---          20/08/2022  2:16 PM       26214400 PowerShell-7.2.6-win-x64.part4.rar
-a---          20/08/2022  2:16 PM         893179 PowerShell-7.2.6-win-x64.part5.rar

With the following code, I can confirm that it does seem to handle the multipart archive:

using SevenZip;

string path = @"C:\Users\Fots\Downloads\PowerShell-7.2.6-win-x64.part1.rar";

SevenZipBase.SetLibraryPath(@"C:\Users\Fots\scoop\apps\7zip\current\7z.dll");
using SevenZipExtractor extractor = new(path);
extractor.ExtractArchive(@"C:\testing");

And as you can see, the extracted file is identical to the original MSI:

PS C:\Users\Fots\source\MultiTest.SevenZipSharp> dir C:\Users\Fots\Downloads\PowerShell-7.2.6-win-x64.msi, C:\testing\PowerShell-7.2.6-win-x64.msi

    Directory: C:\Users\Fots\Downloads

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          19/08/2022  3:11 PM      106954752 PowerShell-7.2.6-win-x64.msi

    Directory: C:\testing

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          19/08/2022  3:11 PM      106954752 PowerShell-7.2.6-win-x64.msi

PS C:\Users\Fots\source\MultiTest.SevenZipSharp> Get-FileHash C:\Users\Fots\Downloads\PowerShell-7.2.6-win-x64.msi, C:\testing\PowerShell-7.2.6-win-x64.msi

Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
SHA256          77566D5B831523C6740C392B64237C52089B574F342A9F51D84ADED24E412CB8       C:\Users\Fots\Downloads\PowerShell-7.2.6-win-x64.msi
SHA256          77566D5B831523C6740C392B64237C52089B574F342A9F51D84ADED24E412CB8       C:\testing\PowerShell-7.2.6-win-x64.msi

Perhaps with your experience of the 7-Zip SDK, you would be able to understand how that library does it. I honestly really love the way your library works and would prefer to use it if possible. 😄

Huge thanks!
Fotis

@fgimian
Copy link

fgimian commented Aug 20, 2022

The answer at https://sourceforge.net/p/sevenzip/discussion/45797/thread/79ecaee0/ may be helpful.

7z.dll requests another volumes from your app via IArchiveOpenVolumeCallback interface.
So you must implement IArchiveOpenVolumeCallback in IArchiveExtractCallback object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants