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:

Post by gnozal »

Update (both libs)

Changes :
- use option #PureZIP_RecursiveZeroDirs to add empty directories to archive (workaround).
(option #PureZIP_Recursive doesn't do it anymore)

See http://www.purebasic.fr/english/viewtopic.php?t=22607
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (both libs)

Changes :
- fixed help file (was wrong version, sorry)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Thorsten1867
Addict
Addict
Posts: 1372
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Post by Thorsten1867 »

How can I overwrite a file in the zip?

My problem:
- I extract one file from the zip
- I work with it and change it
- I add the changed file to the zip

But, then it seems, I have the file two times in the zip and next time three times and so on.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Thorsten1867 wrote:How can I overwrite a file in the zip?

My problem:
- I extract one file from the zip
- I work with it and change it
- I add the changed file to the zip

But, then it seems, I have the file two times in the zip and next time three times and so on.
You can't : ZLIB does not provide any function to delete / update a file in an archive.
You could :
- use the ZLIB 'raw' functions
or
- extract the files you want to keep, erase and rebuild the archive
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
yoxola
Enthusiast
Enthusiast
Posts: 386
Joined: Sat Feb 25, 2006 4:23 pm

Post by yoxola »

When I tried PureZIP for 4.0, I found the examples aren't updated to PB4 syntax and I go this:

PureZIP_SetCallack() is not a function, array, macro or linked list.

I have no clue about what it is :|
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

yoxola wrote:When I tried PureZIP for 4.0, I found the examples aren't updated to PB4 syntax and I go this:

PureZIP_SetCallack() is not a function, array, macro or linked list.

I have no clue about what it is :|
Yes, you are right : 2 examples were not updated. It is fixed now (please download again).

About the callback :
Old function PureZIP_SetCallback() was renamed to PureZIP_SetProgressionCallback(), and there is a new function PureZIP_SetCompressionCallback().
PureZIP_SetProgressionCallback() wrote:Set PureZIP progression callback address for the functions :
- PureZIP_ExtractFiles()
- PureZIP_AddFiles()
The callback is called each time a new file is processed.
Usefull to indicate the progress when many files are packed / unpacked.
PureZIP_SetCompressionCallback() wrote:Set PureZIP (de)compression callback address for the functions :
- PureZIP_Archive_Compress()
- PureZIP_Archive_Extract()
- PureZIP_ExtractFile()
- PureZIP_AddFile()
- PureZIP_ExtractFiles()
- PureZIP_AddFiles()
The callback is called in realtime during compression or decompression.
Usefull to indicate the progress when a big file is packed / unpacked.
See the new MiniZIP/MiniUNZIP sources for an example using both callbacks.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
yoxola
Enthusiast
Enthusiast
Posts: 386
Joined: Sat Feb 25, 2006 4:23 pm

Post by yoxola »

Thanks, it works now :)

Blame me, I should read the document when stuck....
I didn't notice the change.

Great thanks , this lib is pretty useful :)
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

Hello gnozal,

i try to test your lib with a 300 MB-Zip containing a single 2.2 GB-File. The
ZIP-File is correct (tested with WinZip) and there is enough space on my
harddisk but the Returnvalue of PureZIP_ExtractFiles is always #False.

Is there a restriction on files greater 2 GBs?

Thanks in advance & Greetings ... Kiffi
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Kiffi wrote:Hello gnozal,

i try to test your lib with a 300 MB-Zip containing a single 2.2 GB-File. The
ZIP-File is correct (tested with WinZip) and there is enough space on my
harddisk but the Returnvalue of PureZIP_ExtractFiles is always #False.

Is there a restriction on files greater 2 GBs?

Thanks in advance & Greetings ... Kiffi
Hmm, I don't know what the ZLIB (from http://www.winimage.com/zLibDll/) limit is ...
PureZIP_ExtractFiles() returns #False if one of the involved ZLIB functions like unzOpen() fails, or if no file in the archive matches with the filemask.
Maybe you could try to unpack this file with the PureZIP_Archive_* functions ?

Note that ZLIB does not support the 'new' WinZIP compression algorithm PPMd.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

> Maybe you could try to unpack this file with the PureZIP_Archive_*
> functions ?

yes, i can read the content of the zip-file with PureZIP_Archive_Read() and
PureZIP_GetFileInfo(), but the uncompressed size is wrong (i think, this is the
reason why i cannot extract the file(?)).

Image

// Edit:
zlib_faq wrote:# Can zlib work with greater than 4 GB of data?

Yes. inflate() and deflate() will process any amount of data correctly. Each
call of inflate() or deflate() is limited to input and output chunks of the
maximum value that can be stored in the compiler's "unsigned int" type,
but there is no limit to the number of chunks. Note however that the
strm.total_in and strm_total_out counters may be limited to 4 GB. These
counters are provided as a convenience and are not used internally by
inflate() or deflate(). The application can easily set up its own counters
updated after each call of inflate() or deflate() to count beyond 4 GB.
compress() and uncompress() may be limited to 4 GB, since they operate
in a single call. gzseek() and gztell() may be limited to 4 GB depending on
how zlib is compiled. See the zlibCompileFlags() function in zlib.h.

The word "may" appears several times above since there is a 4 GB limit
only if the compiler's long type is 32 bits. If the compiler's long type is 64
bits, then the limit is 16 exabytes.
http://www.zlib.net/zlib_faq.html#faq32

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

Post by gnozal »

Purebasic longs are signed [range : 0 - 2GB], so FileInfo\unCompressedSize is negative !
And I am verifying if FileInfo\unCompressedSize >= 0 ....

I have removed the test in this beta lib : http://people.freenet.de/gnozal/PureZIP_BETA.zip
Could you try it ?

REM : Of course the progression in PureZIP_SetCompressionCallback() will be false !
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

gnozal wrote:Purebasic longs are signed [range : 0 - 2GB], so FileInfo\unCompressedSize is negative !
so now with PB4 you can use Quads ;-)
gnozal wrote:Could you try it ?
now the file was extracted correctly :D
gnozal wrote:REM : Of course the progression in PureZIP_SetCompressionCallback() will be false !
yes, that's a pitty, because my progressbar doesn't work anymore :cry:

Thank you for your help!

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

Post by gnozal »

Kiffi wrote:
gnozal wrote:Purebasic longs are signed [range : 0 - 2GB], so FileInfo\unCompressedSize is negative !
so now with PB4 you can use Quads ;-)
Yes, I think I will update the PB4.00 lib using quads.
Kiffi wrote:
gnozal wrote:Could you try it ?
now the file was extracted correctly :D
:D
Kiffi wrote:
gnozal wrote:REM : Of course the progression in PureZIP_SetCompressionCallback() will be false !
yes, that's a pitty, because my progressbar doesn't work anymore :cry:
It should be OK if I use quads.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

I have added quads in this beta lib : http://people.freenet.de/gnozal/PureZIP_BETA.zip [Not tested]
Could you try it ?

It should :
- accept files up to 4 GB
- display correct progression for files > 2 GB
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Kiffi
Addict
Addict
Posts: 1485
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Post by Kiffi »

gnozal wrote:Could you try it ?
sorry, same behaviour as before: PureZIP_ExtractFiles returns #Null and the
uncompressed filesize is negative.

Greetings ... Kiffi
Post Reply