Page 1 of 40

PureZIP library : ZIP / UNZIP files

Posted: Mon May 30, 2005 8:06 am
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.

Posted: Mon May 30, 2005 8:21 am
by dracflamloc
very cool, whats your license for this

Posted: Mon May 30, 2005 8:25 am
by gnozal
dracflamloc wrote:very cool, whats your license for this
My license : freeware :D
ZLIB's license : see the help files ( RTFM :wink: )

Posted: Mon May 30, 2005 9:07 am
by zikitrake
:D Great. This facilitates much to me the work.... in my work.

Thank you

Posted: Mon May 30, 2005 11:27 am
by Num3
Pretty cool !

Thanks !

Posted: Mon May 30, 2005 12:40 pm
by Bonne_den_kule
You deliver allways the best libraries.
Very good work :)

Re: PureZIP library : ZIP / UNZIP files

Posted: Mon May 30, 2005 2:15 pm
by NoahPhense
VERY VERY nice!

- np

*edit* Where does one find Pupils Library Importer?

Re: PureZIP library : ZIP / UNZIP files

Posted: Mon May 30, 2005 2:49 pm
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..

Re: PureZIP library : ZIP / UNZIP files

Posted: Mon May 30, 2005 2:52 pm
by NoahPhense
Thanks, much apprecited.

- np

Posted: Mon May 30, 2005 6:50 pm
by Droopy
Thanks a lot :D

Posted: Mon May 30, 2005 7:54 pm
by Fred
Cool lib :)

Posted: Mon May 30, 2005 8:14 pm
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%

Posted: Tue May 31, 2005 8:24 am
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

Posted: Tue May 31, 2005 2:40 pm
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 !

Posted: Tue May 31, 2005 2:48 pm
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: