Forum > Packages and Libraries
7zip DLL is super broken
domasz:
Has anyone actually used 7zip DLL in a Delphi/Lazarus application?
In both Delphi and Lazarus it's super broken.
The lib is available in many places, here's one:
https://github.com/PascalVault/Lazarus_7zip
Here's a sample code:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var Arch: I7zOutArchive; Str: TFileSTream; begin Arch := CreateOutArchive(CLSID_CFormat7z); Arch.AddFile('C:\7z.dll', '7z.dll'); Arch.AddFile('C:\change.log', 'change.log'); SetCompressionLevel(Arch, 9); SevenZipSetCompressionMethod(Arch, m7LZMA); Arch.SetPropertie('MT', 'off'); //disabled multi-threading. When MT is on progress bar doesn't work Arch.SetProgressCallback(nil, @ProgressCallback); Str := TFileSTream.Create('C:\tesssst.7z', fmCreate); Arch.SaveToStream(Str); Str.Free;end;
This does work but it compresses using LZMA2 not LZMA. And the compression level is not 9. It's always the same.
rvk:
--- Quote from: domasz on September 11, 2024, 10:11:04 am ---In both Delphi and Lazarus it's super broken.
--- End quote ---
What makes you think the DLL itself is broken?
I have a unit in Delphi which uses LZMA and not LZMA2 in your example (although in my source the compression-level also doesn't do much).
So it's your pascal source which doesn't correctly address the DLL.
domasz:
If you use DLL from old 7zip (for example version 9.20) the default compression is LZMA. If you newest DLL (v. 24) the default compression is LZMA2.
Upgrade your project to newest DLL and see if it still compresses with LZMA.
rvk:
Ha, yes. I did the test in Delphi (which is 32 bit) and had a rogue 7z.dll in my path :-[
It does seem that the default is LZMA2 now.
But... you have this in the source:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- T7zCompressionMethod = (m7Copy, m7LZMA, m7BZip2, m7PPMd, m7Deflate, m7Deflate64);
m7LZMA will default to LZMA2 now.
How would you force LZMA then?
It still might not be a problem with the 7z.dll itself but with the passing of LZMA (and not the default) to that newer DLL.
In your case the m7LZMA should be probably be m7LZMA_default (or m7LZMA2) and you need to add a m7LZMA_old or something.
But I'm not sure what the correct value for property 0 is for LZMA.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---type T7zCompressionMethod = (m7Copy, m7LZMA, m7BZip2, m7PPMd, m7Deflate, m7Deflate64); // <------- procedure SevenZipSetCompressionMethod(Arch: I7zOutArchive; method: T7zCompressionMethod);begin Arch.SetPropertie('0', SevCompressionMethod[method]);end;
rvk:
BTW mORMot2 has this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- T7zCompressionMethod = ( m7Copy, m7Lzma, mzLzma2, m7BZip2, m7Ppmd, m7Deflate, m7Deflate64); SevCompressionMethod: array[T7zCompressionMethod] of WideString = ( 'COPY', 'LZMA', 'LZMA2', 'BZIP2', 'PPMD', 'DEFLATE', 'DEFLATE64');So there they do have a distinction between LZMA and LZMA2.
(Haven't tested it there yet with the latest dll, I will try later.)
Navigation
[0] Message Index
[#] Next page