PureZIP library : ZIP / UNZIP files

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

Moderator: gnozal

X
Enthusiast
Enthusiast
Posts: 311
Joined: Tue Apr 04, 2006 6:27 am

Post by X »

Any chance of a 64bit version of this ... ?
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

gnozal wrote:It looks like a debugger issue !?
Just yesterday ts-soft hast a released a similar LIB like yours:

http://www.purebasic.fr/english/viewtopic.php?t=36420

I had the same problem with UseOGGSoundDecoder() but as you already mentioned it works if you turn off the debugger and remove all 'Debug' keywords. Now I tried the same with your LIB but I didn't work.
gnozal wrote:It works without it ... :shock:
No, it doesn't. But I know why you assumed it works. You have tested your first example and not mine, right? It took me quite a while to figure it out but there is one more important thing:

If you you embed more than 1 file per IncludeBinary the ZIP-file has to be the last file.

Example #1: Working.

Code: Select all

DataSection
   pblogo:
   IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\PureBasicLogo.bmp"   
   geebee:
   IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\Geebee2.bmp"
   skybox:
   IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\skybox.zip"
EndDataSection
Example #2: Fails.

Code: Select all

DataSection
   pblogo:
   IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\PureBasicLogo.bmp"   
   skybox:
   IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\skybox.zip"
   geebee:
   IncludeBinary #PB_Compiler_Home + "Examples\Sources\Data\Geebee2.bmp"   
EndDataSection
But again, this is only important if you have UseOGGSoundDecoder() in your source.

Other than that, it's working without a flaw. :o
X wrote:Any chance of a 64bit version of this ... ?
+1 :P
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Fluid Byte wrote:... You have tested your first example and not mine, right?
Yes.
This problem doesn't exist with PureLZMA, because you can read an archive directly from memory.

Code: Select all

DataSection
  ArchiveBufferStart:
  IncludeBinary "c:\purebasic430\program\MemArchiveTest.arc"
  ArchiveBufferEnd:
EndDataSection
;
If PureLZMA_MemArchive_Read(?ArchiveBufferStart, ?ArchiveBufferEnd - ?ArchiveBufferStart)
  Status = PureLZMA_MemArchive_FindFirst()
  ;
  While Status
    ;
    If PureLZMA_MemArchive_GetArchiveInfo(@ArchiveInfo.LZMA_ArchiveInfo)
      Debug "----------------"
      Debug "CRCUnpacked    = $" + RSet(Hex(ArchiveInfo\CRCUnpacked, #PB_Long), 8, "0")
      Debug "CRCPacked      = $" + RSet(Hex(ArchiveInfo\CRCPacked, #PB_Long), 8, "0")
      Debug "CRCPacked CALC = $" + RSet(Hex(PureLZMA_MemArchive_GetCRC(), #PB_Long), 8, "0")
      Debug "LengthUnpacked = " + Str(ArchiveInfo\LengthUnpacked)
      Debug "LengthPacked   = " + Str(ArchiveInfo\LengthPacked) + " (" + StrF(ArchiveInfo\LengthPacked / ArchiveInfo\LengthUnpacked * 100, 2) + "% of original)"
      Debug "LZMAFlags      = " + Str(ArchiveInfo\LZMAFlags)
      Debug "FileAttributes = $" + Hex(ArchiveInfo\FileAttributes)
      Debug "Filename       = '" + ArchiveInfo\Filename + "'"
    EndIf
    ;
    Status = PureLZMA_MemArchive_FindNext()
    ;
  Wend
  ;
  PureLZMA_MemArchive_Close()
EndIf
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

Hi gnozal,

Please can you add a function like PureZip_Version$ to get the current
version of PureZIP ? I use the Menu-Entry 'More Infos' in one of my Tools
to get informations of used libraries and I miss a function like that.

BTW:
Do you plan to re-adding support for add empty directorys to zip ?
In my filemanager I can't no longer use the 'MakeDirectory_to_Zip'
function.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Update (all versions)

Changes :
- new function : PureZIP_Archive_GlobalComment()
- new function : PureZIP_GetVersion()
- fixed broken #PureZIP_RecursiveZeroDirs in PureZIP_AddFiles()
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

This was very fast, thanks gnozal. :D
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Just wanted to shout a big Thanks to this great lib!

But one question anyway:

Is it possible to remove Files/ Folders from an Archive?
Tranquil
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Tranquil wrote:Is it possible to remove Files/ Folders from an Archive?
Afaik, ZLIB does not offer any function to delete a file from an archive.
I suppose one could do it using the 'raw' functions, but I didn't try.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Kukulkan
Addict
Addict
Posts: 1396
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Post by Kukulkan »

Hi gnozal,

at first, thank you for this great lib. I use it in a project to compress files using

Code: Select all

PureZIP_AddFile(ZIPFilename.s, OriginalFilename.s, 0)
Now, another one needs to decompress the file using ZLIB functions on Java ME. But he is not able to do so (errors). Can you please give me some information about the algorithm and parameters you use in ZLIB for compression in PureZIP? Is it possible to get the part of code for this call to ZLIB with the corresponding parameters and values?

Or can you tell me the exact ZLIB call to decompress such a file?

Maybe this can help him...

Thank you,

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

Post by gnozal »

Kukulkan wrote:Can you please give me some information about the algorithm and parameters you use in ZLIB for compression in PureZIP? Is it possible to get the part of code for this call to ZLIB with the corresponding parameters and values?
I use this ZLIB version : http://www.winimage.com/zLibDll/ ; it has some 'PKZIP high level' functions. The ZLIB version available at www.zlib.net doesn't.
I use the #Z_BEST_COMPRESSION compression flag.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Okay, back again and still working on ZIP Archive support for my filemanager using your great lib.

Just one little question again:

As it is not possible to remove/ delete a file/directory directly from the archive it is necessary to re-compress the whole archive. This could be speed up a bit if it would be possible to extract an already compressed file and put this to archive again without the need of compressing it again.
This could be something like: PureZIP_GetFile() and PureZIP_PutFile().

Maybe this is possible?
Tranquil
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Tranquil wrote:As it is not possible to remove/ delete a file/directory directly from the archive it is necessary to re-compress the whole archive. This could be speed up a bit if it would be possible to extract an already compressed file and put this to archive again without the need of compressing it again.
This is what I do with PureLZMA-Packer.
Tranquil wrote:Maybe this is possible?
It should be possible using the ZLIB 'raw' functions ; but I have no experience here. Maybe I will have a closer look when I have some time.
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

Post by besko »

gnozal are you test this lib with files size more then 6gb?
not working for me (

And how i can pack files in folder if i want pack custom files to different zip files.
Example:
Folder -My Files/
/photo1.jpg
/money.doc
/etc.

i want to get
/photo1.zip
/money.zip

:)
User avatar
mk-soft
Always Here
Always Here
Posts: 6207
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Post by mk-soft »

Not so loud

all fully compatiblen ZIP.DLL does not produce archives over 2GB
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

besko wrote:gnozal are you test this lib with files size more then 6gb?
not working for me (
PureZIP.CHM wrote:ZLIB can handle files up to 4 Gbytes, but PB longs are signed [0 - 2 Gbytes]...
So if you expect PureZIP_FileInfo\CompressedSize > 2 Gbytes or PureZIP_FileInfo\unCompressedSize > 2 Gbytes,
use quads and convert signed to unsigned !
Example : Size.q = FileInfo\unCompressedSize & $FFFFFFFF
ZLIB doesn't support files > 4 GB
besko wrote:And how i can pack files in folder if i want pack custom files to different zip files.
I don't understand what you mean.
If the 'high level' functions like PureZIP_AddFiles() don't provide the functionality you need, use the 'low level' functions [PureZIP_Archive_*()].

Finally, you could try MiniZIP.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply