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 »

fizban wrote:You must have done something additional. I couldn't find a lib that worked with PB there. Besides, there are some references to purezip inside your lib...
It's the DLL from WinImage (link in my previous post) transformed to a static library. But I've also used the regular static lib from WinImage, and it works likewise (in PureZIP).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
fizban
User
User
Posts: 31
Joined: Thu Sep 20, 2007 7:36 am
Location: Spain

Post by fizban »

Oh. I didn't know that was possible. How did you transform the dll into a lib? I have googled it and only found a $999 tool and a free python script...
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

fizban wrote:Oh. I didn't know that was possible.
It is, but probably not for all DLLs. And there might be some big dependancy problems.
fizban wrote:How did you transform the dll into a lib?
I didn't.
A friend of mine is a developer and has such tools (DLL2LIB I believe ?).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
fizban
User
User
Posts: 31
Joined: Thu Sep 20, 2007 7:36 am
Location: Spain

Post by fizban »

If it is dll2lib, looking at their license statement, "BSI grants you a non-exclusive royalty-free right to compile, reproduce and distribute the static libraries, DLLs, components, header files, source files (the "REDISTRIBUTABLES") or new software programs created using THE SOFTWARE".
So, my interpretation is that it safe to use this lib commercially, licensewise.
fizban
User
User
Posts: 31
Joined: Thu Sep 20, 2007 7:36 am
Location: Spain

Post by fizban »

Just in case, I downloaded Visual C++ Express 2005 and the platform SDK 2008 and I rebuilt zlibstat.lib. It was easier than I expected. The worst thing was downloading all those megs just to compile this small library. The resulting lib is larger than yours, though, but a little bit smaller than the one at winimage. Using this new zlibstat I get a smaller executable than with yours. It might be related to the dll to lib conversion... I can send it to you if you want so that you can make it available to others...
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

fizban wrote:I can send it to you if you want so that you can make it available to others...
That would be nice, thanks.
[EDIT] Got it, thanks. See my PM.
Last edited by gnozal on Tue Aug 26, 2008 1:25 pm, edited 1 time in total.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
graves
Enthusiast
Enthusiast
Posts: 160
Joined: Wed Oct 03, 2007 2:38 pm
Location: To the deal with a pepper

Exceptions on AddFiles

Post by graves »

Hi, gnozal,
I'm using PureZip_AddFiles command with #PureZIP_Recursive flag activated.

On "FileMask" parameter I need to specify some mask to not add "*.pst" files (they are very big). Is possible that mask?.

Yes. I can make ExamineDirectory() and then PureZIP_AddFile for every entry (except pst files), I know that, but #PureZIP_Recursive is very useful.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Exceptions on AddFiles

Post by gnozal »

graves wrote:On "FileMask" parameter I need to specify some mask to not add "*.pst" files (they are very big). Is possible that mask?.
Sorry, you can't do that. PureZip_AddFiles() is only a convenient wrapper to the PureZIP_Archive_*() functions.
My advise is to scan the directory using ExamineDirectory() and archive the files you need using the PureZIP_Archive_*() functions.

Something like this (not tested, but you get the idea) :

Code: Select all

Global NewList FileList.s()
Procedure DirectoryListing(Recursive.l, Directory.s)
  Protected MyDir.l, FullFileName.s, FileName.s
  MyDir = ExamineDirectory(#PB_Any, Directory, "*.*")
  If MyDir
    Repeat
      If NextDirectoryEntry(MyDir) = 0
        Break
      EndIf
      FileName = DirectoryEntryName(MyDir)
      If Right(Directory, 1) <> ""
        Directory = Directory + ""
      EndIf
      FullFileName = Directory + FileName
      If DirectoryEntryType(MyDir) = #PB_DirectoryEntry_Directory And Recursive 
        If FileName <> "." And FileName <> ".."
          DirectoryListing(Recursive, Directory + FileName)
        EndIf
      ElseIf DirectoryEntryType(MyDir) = #PB_DirectoryEntry_File
        If LCase(GetExtensionPart(FileName)) <> "pst"
          AddElement(FileList())
          FileList() = FullFileName
        EndIf
      EndIf
    ForEver
    FinishDirectory(MyDir)
  EndIf
EndProcedure
DirectoryListing(#True, "c:\MyTestDir")
If CountList(FileList())
  If PureZIP_Archive_Create("MyZIP", #APPEND_STATUS_CREATE)
    ForEach FileList()
      PureZIP_Archive_Compress(FileList(), #True)
    Next
    PureZIP_Archive_Close()
  EndIf
EndIf
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,

Is it possible to decompress data, compressed using PureZIP library, directly bu using ZLIB functions? Or is there a special header added to PureZIP compressed data? How to manage?

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

Post by gnozal »

Hi
Kukulkan wrote:Is it possible to decompress data, compressed using PureZIP library, directly by using ZLIB functions?
Yes
Kukulkan wrote:Or is there a special header added to PureZIP compressed data?
No.
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,

I have a file that was packed using PureZIP. I can decompress it with WinZIP or RAR and it works great.

If I try to use ZLIB to decompress, it tells me that the data was corrupt! The header starts with PK, but is this for ZLIB compression?

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:If I try to use ZLIB to decompress, it tells me that the data was corrupt!
What ZLIB functions do you use ?
Note that you have to use ZIP compatible functions like unzOpen() - unzGoToFirstFile() etc ...
Kukulkan wrote: The header starts with PK, but is this for ZLIB compression?
The 'PK' header is the classic PKZIP header. It has nothing to do with ZLIB.
I meant PureZIP doesn't add any extra header.
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,

My current problem is, that I decrypt some previous zip compressed file into memory. Now I need to unzip the data in memory, but PureZIP does not offer a function to unzip a ZIP file that is located in memory. Currently I solve this by storing the content temporarely on disk to use PureZIP_ExtractFile() function. But this is not a good solution. I need some PureZIP_ExtractFileFromMemory() function. By the way, a corresponding PureZIP_AddFileToMemory() function will be great, too.

To clearify: The memory content is a ZIP file in memory (PK...). The PureZIP_PackMemory() and PureZIP_UnpackMemory() functions do not work with ZIP-file in memory (it is DEFLATE compressed?).

My Idea has been to use another ZLIB library, but this one is not able to use a ZIP-file in memory, too :cry:

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:To clearify: The memory content is a ZIP file in memory (PK...). The PureZIP_PackMemory() and PureZIP_UnpackMemory() functions do not work with ZIP-file in memory (it is DEFLATE compressed?).
AFAIK, the ZLIB ZIP compatible functions only allow to open an archive from disk, not from memory : I don't know a function like unzOpen() for a memory bank.
It is certainly possible using some ZLIB base functions like deflate(), but you'll have to manage all the header stuff manually. I never tried that, sorry.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Inner
PureBasic Expert
PureBasic Expert
Posts: 714
Joined: Fri Apr 25, 2003 4:47 pm
Location: New Zealand

Post by Inner »

4.30 beta 2 & 3 of Purebasic reports;

The following PureLibrary is missing: StringExtension
Post Reply