Add compression levels to ZipPacker

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
sartic
Enthusiast
Enthusiast
Posts: 143
Joined: Thu Aug 26, 2010 8:26 am

Add compression levels to ZipPacker

Post by sartic »

store, fast and max
thx.
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
sartic
Enthusiast
Enthusiast
Posts: 143
Joined: Thu Aug 26, 2010 8:26 am

Re: Add compression levels to ZipPacker

Post by sartic »

not even one msg of support :(
Registered user of PB (on Linux Mint 21.1 & Win 10 64bit)
ergrull0
User
User
Posts: 23
Joined: Sat Mar 08, 2014 4:45 pm

Re: Add compression levels to ZipPacker

Post by ergrull0 »

sartic wrote:not even one msg of support :(
I'm supporting you! :mrgreen:
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Add compression levels to ZipPacker

Post by idle »

temporary workaround

Code: Select all

EnableExplicit

CompilerIf #PB_Compiler_OS = #PB_OS_Windows 
  ImportC "zlib.lib"
    compress2(*dest,*destlen,*source,sourcelen,level)
 EndImport 
CompilerElse 
  ImportC "-lz"   
    compress2(*dest,*destlen,*source,sourcelen,level)
  EndImport 
CompilerEndIf 

Procedure AddPackFile2(Pack,FileName$,PackedFilename$,level=9)
   Protected fn,*output,*input,outlen,filelen,result 
   
   fn = ReadFile(#PB_Any,FileName$) 
   If fn 
      filelen = Lof(fn)
      outlen = filelen * 1.5
      *input = AllocateMemory(filelen)
      *output = AllocateMemory(outlen)
       If *input And *output  
          If  ReadData(fn,*Input,Filelen) = filelen 
             If Compress2(*output,@outlen,*Input,Filelen,level) = 0  
                Result =  AddPackMemory(Pack, *output, outlen, PackedFilename$)
             EndIf   
          EndIf 
          FreeMemory(*input)
          FreeMemory(*output)
       EndIf   
      CloseFile(fn) 
   EndIf
   
   ProcedureReturn Result 
   
EndProcedure    

UseZipPacker()

Define file.s,packfile.s,extn.s,pack.i
file = OpenFileRequester("Choosefile","","*.*",1) 
extn = GetExtensionPart(file)
packfile = Left(file,Len(file)-Len(extn)) + "zip"
pack = CreatePack(#PB_Any,packfile,#PB_PackerPlugin_Zip )  
AddPackFile2(pack,file,packfile,9)
ClosePack(pack) 


Windows 11, Manjaro, Raspberry Pi OS
Image
PMV
Enthusiast
Enthusiast
Posts: 727
Joined: Sat Feb 24, 2007 3:15 pm
Location: Germany

Re: Add compression levels to ZipPacker

Post by PMV »

sartic wrote:not even one msg of support :(
Which support? :shock:

You will never get an answer from the dev-team, but they
read your wish. Thats for sure! So nothing to worry. :)
Post Reply