PureZIP library : ZIP / UNZIP files

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

PureZIP library : ZIP / UNZIP files

Post by gnozal »

PureZIP library [ PB 3.9x-4.31 : V1.96 (FEB 25th 2009) ; PB 4.4x-4.5x : V2.00 (AUG 18th 2009) ; PB4.6x : V2.33 (MAR 9th 2012) ; PB5.0x : V2.33 (NOV 7th 2012) ; DLL : V2.00a (SEP 24th 2011) ]

Overview

Code: Select all

The purpose of PureZIP is to handle ZIP files.
It uses the ZLIB library 1.2.3 (c) 1995-2004 Jean-loup Gailly and Mark Adler modified by Gilles Vollant.

The library supports classic PKZIP 2.04g archives :
- compression
- extraction
- encryption (ZIP 2.0)
... and for the latest versions :
- file deletion in archive
- file renaming in archive
- read archive from memory
Functions
PB3.94 : http://gnozal.ucoz.com/PureZIP.htm
PB4.xx : http://gnozal.ucoz.com/PureZIP_.htm

Example

Code: Select all

Procedure CallbackForTest(file.s, PerCent.f)
  Debug StrF(PerCent, 2) + "%"
EndProcedure
;
myFileinfo.PureZIP_FileInfo
PureZIP_SetProgressionCallback(@CallbackForTest())
;
MyZIP.s = "C:\PureBasic393\Program\PureZIP\essai1\test.zip"
MyFilesToZIP.s = "C:\PureBasic393\Program\PureBriefLZ\*.*"
MyZIPOutPut.s = "C:\PureBasic393\Program\PureZIP\essai3\"
; Create archive
Debug PureZIP_AddFiles(MyZIP, MyFilesToZIP, #PureZIP_StorePathAbsolute, #PureZIP_Recursive)
; Extract files from archive
Debug PureZIP_ExtractFiles(MyZIP, "*.*", MyZIPOutPut, #TRUE)
; Count files in archive
Debug PureZIP_GetFileCount(MyZIP)
; Add memory bank to archive
Debug PureZIP_AddMemory(MyZIP, "MemoryTest.txt", @MyZIP, Len(MyZIP))
; On file more in archive :
Debug PureZIP_GetFileCount(MyZIP)
; Get files information
For i = 0 To PureZIP_GetFileCount(MyZIP) - 1
   Debug PureZIP_GetFileInfo(MyZIP,i , @myFileinfo)
   Debug "Number " + Str(i)
   Debug "Filename: " + myFileinfo\FileName
   Debug "Compressed Size: " + Str(myFileinfo\CompressedSize)
   Debug "Uncompressed Size: "+ Str(myFileinfo\unCompressedSize)
   Debug "--------------"
Next
Download
Only available for Purebasic Windows x86
PB3.94 : http://gnozal.ucoz.com/PureZIP.zip
PB4.0x - 4.10 : http://gnozal.ucoz.com/PureZIP_.zip
PB4.20 : http://gnozal.ucoz.com/PureZIP___.zip
PB4.3x : http://gnozal.ucoz.com/PureZIP_430.zip
PB4.4x : http://gnozal.ucoz.com/PureZIP_440.zip
PB4.5x : http://gnozal.ucoz.com/PureZIP_450.zip
PB4.6x : http://gnozal.ucoz.com/PureZIP_460.zip
PB5.0x : http://gnozal.ucoz.com/PureZIP_500.zip

Shared library (DLL) : http://gnozal.ucoz.com/PureZIP_DLL.zip [based on UserLib for PB4.xx code]

Notes :
1. Unicode : the ZIP standard doesn't support unicode files names. In a (PKZIP 2.04g) ZIP archive, the filenames are stored as OEM (MS-DOS, remember ?). The unicode version of PureZIP translates unicode to OEM and vice-versa. It works, but it is not 'true' unicode support...
Some newer archivers (like Pkzip 4.5+ / Winzip 11.2+) store unicode names using the UTF-8 standard. This method isn't compatible with older ZIP packers. Others store Unicode names in an extra field (like the Info-Zip method). But there is no real standard. If you need real unicode support, better use RAR or 7-ZIP.
2. Archive size : PureZIP (ZLIB) should support archive sizes up to 4GB. However ZIP is not recommended for big archives, because some compressors achieve much better compression ratio (RAR, 7-ZIP, ...), and ZIP doesn't have recovery capabilities like RAR for example.
3. GZ archives : PureZIP does not support GZ archives ; you may however try the following include + static ZLIB.
Last edited by gnozal on Tue Aug 18, 2009 11:51 am, edited 41 times in total.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

very cool, whats your license for this
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

dracflamloc wrote:very cool, whats your license for this
My license : freeware :D
ZLIB's license : see the help files ( RTFM :wink: )
Last edited by gnozal on Mon May 30, 2005 12:46 pm, edited 1 time in total.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
zikitrake
Addict
Addict
Posts: 834
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Post by zikitrake »

:D Great. This facilitates much to me the work.... in my work.

Thank you
Num3
PureBasic Expert
PureBasic Expert
Posts: 2810
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Pretty cool !

Thanks !
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

You deliver allways the best libraries.
Very good work :)
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: PureZIP library : ZIP / UNZIP files

Post by NoahPhense »

VERY VERY nice!

- np

*edit* Where does one find Pupils Library Importer?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: PureZIP library : ZIP / UNZIP files

Post by gnozal »

NoahPhense wrote:Where does one find Pupils Library Importer?
Here :
Pupil wrote:Hmm, seems like i've forgotten about this, i'm sure i said something about releasing it at the time, but it never happened ;) i'm soo lazy :)

Anyway, for a limited time you can all download it from here (i don't know how long it'll be there so just grab it):
http://w1.319.telia.com/~u31913785/gnoz ... er_new.zip

The importer is a modified version of the original made by Fr34k. I've added a little workaround for LIB's with C calling convention and the possibility to save/load a project..
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: PureZIP library : ZIP / UNZIP files

Post by NoahPhense »

Thanks, much apprecited.

- np
User avatar
Droopy
Enthusiast
Enthusiast
Posts: 658
Joined: Thu Sep 16, 2004 9:50 pm
Location: France
Contact:

Post by Droopy »

Thanks a lot :D
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Cool lib :)
Num3
PureBasic Expert
PureBasic Expert
Posts: 2810
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Okey, got these problems here...

When i created my own functions i tested them on pebuilder.iso which is 340Mb, but i can't seem to pack the same file with PureZIP_AddFiles() it always throws an error...

Funny thing is, if i pack the entire directory where pebuilder.iso is, using *.* instead of the single file name it works!

So "D:\pebuilder\*.*" works, "D:\pebuilder\pebuilder.iso" does not!

Also the page file hits eats +50mb when packing and the CPU hit's 80%, and using my pack procedure i can compress 7 extra megabytes out of the same file...

When packing large files the callback seems to output:
0.00%
20.00%
40.00%
60.00%
80.00%
100.00%
5
20.00%
40.00%
60.00%
80.00%
100.00%
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Num3 wrote:Okey, got these problems here...
It's just V1 :oops:
- I have not tested it with big files, I didn't even think about it. Why would someone use ZIP on big files, when there is 7-ZIP :wink: ?
- The packing function is the same in PureZIP_AddFile() and PureZIP_AddFiles(), but you are right : PureZIP_AddFiles() only worked with wildcards :oops: : it's fixed now.
- The callback function is very primitive : it is only called before each zipOpenNewFileInZip().
- "using my pack procedure i can compress 7 extra megabytes out of the same file..." : What do you mean ? Your zip file is 7 Mb smaller ? I use #Z_DEFLATED & #Z_BEST_COMPRESSION, so I don't know ...
- "Also the page file hits eats +50mb when packing and the CPU hit's 80%" : I have add some delay in the loop, tell me if it helps.

Library updated
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Num3
PureBasic Expert
PureBasic Expert
Posts: 2810
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post by Num3 »

Sorry i didn't mean to sound critic! Your work is excellent!

I can get 7 less mb out of the file, because i'm streaming the iso and maybe, just by plain luck, this file squeazes more like this...

I'll test your changes and report back !
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Num3 wrote:Sorry i didn't mean to sound critic! Your work is excellent!
Constructive criticism and good bug report are always wellcome :D Congratulations also :lol:
Num3 wrote:I'll test your changes and report back
Thanks. I will try to improve it, but I am no expert :wink:
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply