adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.24k stars 480 forks source link

Wav problem #345

Open easly1989 opened 6 years ago

easly1989 commented 6 years ago

Hello there, Trying to Unzip this -> https://github.com/anoyetta/ACT.Hojoring/releases/download/v4.0.12/ACT.Hojoring-v4.0.12.7z I get several errors for every *.wav file it is trying to extract.

The error is: Not supported Method specified (translated from: Specifiato metodo non supportato)

The stack is:

in SharpCompress.Compressors.LZMA.DecoderRegistry.CreateDecoderStream(CMethodId id, Stream[] inStreams, Byte[] info, IPasswordProvider pass, Int64 limit) in SharpCompress.Compressors.LZMA.DecoderStreamHelper.CreateDecoderStream(Stream[] packStreams, Int64[] packSizes, Stream[] outStreams, CFolder folderInfo, Int32 coderIndex, IPasswordProvider pass) in SharpCompress.Compressors.LZMA.DecoderStreamHelper.CreateDecoderStream(Stream inStream, Int64 startPos, Int64[] packSizes, CFolder folderInfo, IPasswordProvider pass) in SharpCompress.Common.SevenZip.ArchiveDatabase.GetFolderStream(Stream stream, CFolder folder, IPasswordProvider pw) in SharpCompress.Common.SevenZip.SevenZipFilePart.GetCompressedStream() in SharpCompress.Archives.SevenZip.SevenZipArchiveEntry.OpenEntryStream() in SharpCompress.Archives.IArchiveEntryExtensions.WriteTo(IArchiveEntry archiveEntry, Stream streamToWriteTo) in SharpCompress.Archives.IArchiveEntryExtensions.WriteToFile(IArchiveEntry entry, String destinationFileName, ExtractionOptions options) in SharpCompress.Archives.IArchiveEntryExtensions.WriteToDirectory(IArchiveEntry entry, String destinationDirectory, ExtractionOptions options) in ActorConsole.Program.Unzip(String installText, String zip, String destination, Boolean deleteDir) in D:\GIT\ffxiv_actor\ActorConsole\Program.cs:riga 191

The code I use to extract is: ` using (var archive = ArchiveFactory.Open(zip)) { var archiveEntries = archive.Entries.Where(x => !x.IsDirectory && !x.IsEncrypted).ToArray(); var count = 1; foreach (var entry in archiveEntries) { try { var value = (100 * count) / archiveEntries.Length; Console.Write($"\r{installText} {value}%"); count++;

                    entry.WriteToDirectory(destination, new ExtractionOptions { ExtractFullPath = true, Overwrite = true });
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                }

            }
        }

`

All the other files gets estracted without any problem.

Any help?

adamhathcock commented 6 years ago

Honestly, I'm not sure off the top of my head. If the LZMA decoder doesn't like wav files I'm not sure how to fix that.

Ugh, I hate the 7Zip format.

easly1989 commented 6 years ago

maybe i'm just doing something wrong. If you, or someone else, would like to try and unzip that file (the link in the OT) maybe you can come up with a solution (or just find out i'm the one messing up)

Thank you for the answer btw

ghost commented 6 years ago

@easly1989 you are not doing anything wrong; WAV files appear to compress using the FILTER_DELTA flag, which is not supported by the current implementation in SharpCompress (in Compressors\LZMA\Registry.CreateDecoderStream, the switch case for k_Delta falls through to the exception you are seeing).

@adamhathcock at some point 7zip started automatically detecting sub-blocks that would be good candidates for having the delta filter applied. This filter reorders the bytes being loaded by some offset, as can be seen from the C code 7zip is based on. The delta state size is set as #define DELTA_STATE_SIZE 256.

It is late where I'm at, so I may just be tired, but I believe this mirrors some of the logic found in LzBinTree in the LZMA SDK.