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:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

Starwolf20 wrote:Hi Gnozal
The 1er post says that PureZip uses Zlib V1.23.
The ZLIB website says that the last version is V1.25. Is an update of PureZip planned ?
Thanks
Hi,
Sometimes ago I tried to update PureZIP with the static library from Gilles Vollant's site, but I didn't manage to use it with PB, because of linker errors iirc.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by User_Russian »

How can I add to ZIP Archive, an empty folder (which does not contain any files) by using the PureZIP_Archive_Compress?
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 [password supported]

Post by gnozal »

User_Russian wrote:How can I add to ZIP Archive, an empty folder (which does not contain any files) by using the PureZIP_Archive_Compress?
You can't !

However, you may use PureZIP_AddFiles() with #PureZIP_RecursiveZeroDirs flag to store empty folders.
But do not use this function within a PureZIP_Archive_Create() / PureZIP_Archive_Close() sequence.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User_Russian
Addict
Addict
Posts: 1443
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by User_Russian »

gnozal wrote:
User_Russian wrote:How can I add to ZIP Archive, an empty folder (which does not contain any files) by using the PureZIP_Archive_Compress?
You can't !

However, you may use PureZIP_AddFiles() with #PureZIP_RecursiveZeroDirs flag to store empty folders.
But do not use this function within a PureZIP_Archive_Create() / PureZIP_Archive_Close() sequence.
I create self-extracting (SFX) archive, using

Code: Select all

PureZIP_Archive_Create(ArchiveFileName.s, #APPEND_STATUS_CREATEAFTER)
Therefore, the function PureZIP_AddFiles () can not be used.
What should do?
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 [password supported]

Post by gnozal »

User_Russian wrote:I create self-extracting (SFX) archive, using

Code: Select all

PureZIP_Archive_Create(ArchiveFileName.s, #APPEND_STATUS_CREATEAFTER).
Therefore, the function PureZIP_AddFiles () can not be used.
What should do?[/quote]
You can create the archive ("archive.zip") and then add the sfx stub ("archive.sfx").

You may use the console (COPY /B archive.sfx+archive.zip archive.exe) or purebasic's file functions.
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:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

Update (PB4.60 version)

Changes :
  - new function : PureZIP_DeleteFile(Archive.s, FileToDelete.s)
  - new function : PureZIP_RenameFile(Archive.s, OldFileName.s, NewFileName.s)
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
besko
User
User
Posts: 42
Joined: Tue Oct 28, 2008 1:08 pm

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by besko »

Gnozal, what about archive size ? Can we rise these nums?
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 [password supported]

Post by gnozal »

besko wrote:Gnozal, what about archive size ? Can we rise these nums?
PureZIP (ZLIB) should support archive sizes up to 2GB.
However I wouldn't use ZIP for big archives, because :
- some compressors achieve much better compression ratio (RAR, 7-ZIP, ...)
- ZIP doesn't have recovery capabilities like RAR for example
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by c4s »

Hi Gnozal, I have two questions:

Is it possible to set the compression level and if not could you please add it?

Also you wrote somewhere that Unicode isn't properly supported. What does that exactly mean?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
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 [password supported]

Post by gnozal »

c4s wrote:Is it possible to set the compression level and if not could you please add it?
You may use PureZIP_SetCompressionAlgorithm() to choose between #Z_NO_COMPRESSION and #Z_DEFLATED.
As #Z_DEFLATED is so fast, PureZIP always uses #Z_BEST_COMPRESSION. There is no point using any other compression level.
c4s wrote:Also you wrote somewhere that Unicode isn't properly supported. What does that exactly mean?
In a (PKZIP 2.04g) ZIP archive, the filenames are stored as OEM (MS-DOS, remember ?). ZLIB does not support the unicode extensions, and every packer has another method to store unicode file names (unicode filenames as UTF-8 : Pkzip 4.5/Winzip 11.2 method, unicode filename in extra field : Info-Zip method, etc...).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by c4s »

gnozal wrote:You may use PureZIP_SetCompressionAlgorithm() to choose between #Z_NO_COMPRESSION and #Z_DEFLATED.
As #Z_DEFLATED is so fast, PureZIP always uses #Z_BEST_COMPRESSION. There is no point using any other compression level.
Users (!) sometimes like to have control over something, even if it doesn't make sense in a programmers point of view. Please just add it to PureZIP_SetCompressionAlgorithm()... I would highly appreciate it!
gnozal wrote:In a (PKZIP 2.04g) ZIP archive, the filenames are stored as OEM (MS-DOS, remember ?). ZLIB does not support the unicode extensions, and every packer has another method to store unicode file names (unicode filenames as UTF-8 : Pkzip 4.5/Winzip 11.2 method, unicode filename in extra field : Info-Zip method, etc...).
OK, but what does that mean for PureZIP? Is Unicode supported in some way?

As far as I remember Microsoft added Zip support to the Windows Explorer in XP. Was it possible to create Zip folders as well? If so, do you know how they managed this issue?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
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 [password supported]

Post by gnozal »

c4s wrote:Users (!) sometimes like to have control over something, even if it doesn't make sense in a programmers point of view. Please just add it to PureZIP_SetCompressionAlgorithm()... I would highly appreciate it!
If you open a ZIP file with 7-ZIP and check the properties, you only get the algorithm (Deflate), but not the compression level. And if you want to create a ZIP file, you have 6 generic compression level options that do not have any meaning, as DEFLATE only has 2 levels (Z_BEST_SPEED and Z_BEST_COMPRESSION)!

So if the user is pleased with meaningless options, just add a trackbar that does nothing... as only 2 options may no satisfy him !

Anyway, I may add PureZIP_SetCompressionLevel() in a future version ... to please my users !
c4s wrote:OK, but what does that mean for PureZIP? Is Unicode supported in some way?
The unicode version of PureZIP translates unicode to OEM and vice-versa. It works, but it is not 'true' unicode support...
c4s wrote:As far as I remember Microsoft added Zip support to the Windows Explorer in XP. Was it possible to create Zip folders as well? If so, do you know how they managed this issue?
I have no idea. I only know that the genuine PKZIP 2.04g archive format does not support unicode, and that some modern archivers use a workaround to store unicode filenames (see my previous post).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by c4s »

gnozal wrote:If you open a ZIP file with 7-ZIP and check the properties, you only get the algorithm (Deflate), but not the compression level. And if you want to create a ZIP file, you have 6 generic compression level options that do not have any meaning, as DEFLATE only has 2 levels (Z_BEST_SPEED and Z_BEST_COMPRESSION)!

So if the user is pleased with meaningless options, just add a trackbar that does nothing... as only 2 options may no satisfy him !
Wikipedia about Deflate says: "Options range from -0 (do not attempt compression, just store uncompressed) to -9 representing the maximum capability of the reference implementation in zlib/gzip."
gnozal wrote:Anyway, I may add PureZIP_SetCompressionLevel() in a future version ... to please my users !
I case it's not meant ironically, thank you. ;-)
gnozal wrote:The unicode version of PureZIP translates unicode to OEM and vice-versa. It works, but it is not 'true' unicode support...
Thanks for explaining!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
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 [password supported]

Post by gnozal »

c4s wrote:Wikipedia about Deflate says: "Options range from -0 (do not attempt compression, just store uncompressed) to -9 representing the maximum capability of the reference implementation in zlib/gzip."
There are two constants, #Z_BEST_SPEED = 1 and #Z_BEST_COMPRESSION = 9, so I guess values 2-8 are valid, never tried it though.
Anyway, it's the same problem : 9 ZLIB values, 6 compression level options in 7-ZIP, so no match between user input and ZLIB function reality.
c4s wrote:I case it's not meant ironically, thank you.
See below..
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:

Re: PureZIP library : ZIP / UNZIP files [password supported]

Post by gnozal »

Update (PB4.60 version)

Changes :
- new function : PureZIP_SetCompressionLevel()
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply