minizip lib

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

minizip lib

Post by ts-soft »

This is a static lib + include, providing zip- und unzip-functions for PB4.30 + (windows only)

Different to other libs, this static lib only includes additional functions
to improve the zlib.lib, which is included in the PB-Package, so incompatibly are very unlikely.

This lib supports x86 as well as x64 platforms,
without any necessary changes in the source code being needed.

Code: Select all

*result = ZIP_PackMemory(*source[, sourceLen[, level]])
	*source = MemoryPointer
	sourceLen = Size of Memory (optional)
	level = compressionslevel (optional)
	
	*result = MemoryPointer to packed memory or 0 if failed
	
result = ZIP_UnpackMemory(*source, *dest)
	result = Size of *dest or 0 if failed
	
void = ZIP_SetPassword([password.s])
	password = password for ZIP or UNZIP

result = ZIP_GetFilesCount(Zip_FileName.s)
	Zip_FileName.s = filename with path
	
	result = count of files/dirs
	
result.s = ZIP_GetFileComment(Zip_FileName.s)
	Zip_FileName.s = filename with path
	
	result is the global comment of the zipfile
	
result.s = ZIP_GetFileInfo(Zip_FileName.s, FileNumber[, *FileInfo.unz_file_info])
	Zip_FileName.s = filename with path
	FileNumber = filenumber in archiv
	*FileInfo = stores all infos in the structure (optional)
	
	result = filename

result = ZIP_GetFileNumber(Zip_FileName.s, FileName.s)
	Zip_FileName.s = filename with path
	FileName = filename with relative path in archiv (not casesensitive)
	
	result = filenumber or 0 if failed

result = ZIP_IsPasswordRequired(Zip_FileName.s, FileNumber)
	Zip_FileName.s = filename with path
	FileNumber = filenumber in archiv

	result = #True, password encrypted, or #False, not password encrypted
	
result = ZIP_ExtractFile(Zip_FileName.s, FileNumber, Output_Path.s[, CreatePath[, Callback]])
	Zip_FileName.s = filename with path
	FileNumber = filefumber in archiv
	Output_Path.s = path to extract file
	CreatePath = #True or #False (#True creates subdirectories in archiv, optional = #True)
	Callback = adress of callbackprocedure, Prototyped as: ZIP_PackerCallback(progress)*
		*you can return #UNZIP_CANCEL from Callback to cancel
	
	result = #True on success

result = ZIP_ExtractArchiv(Zip_FileName.s, Output_Path.s[, CreatePath[, Callback]])
	Zip_FileName.s = filename with path
	Output_Path.s = path to extract file
	CreatePath = #True or #False (#True creates subdirectories in archiv, optional = #True)
	Callback = adress of callbackprocedure, Prototyped as: ZIP_ArchivCallback(progress, files)*
		*you can return #UNZIP_CANCEL from Callback to cancel
	
	result = count of extracted files

*result = ZIP_CatchFile(Zip_FileName.s, FileNumber[, Callback])
	Zip_FileName.s = filename with path
	FileNumber = filenumber in archiv
	Callback = adress of callbackprocedure, Prototyped as: ZIP_PackerCallback(progress)*
		*you can return #UNZIP_CANCEL from Callback to cancel
		
	*result = memorypointer or 0 if failed

result = ZIP_FileCreate(Zip_FileName.s)
	Zip_FileName.s = filename with path
	creates a empty zipfile
	
	result = ziphandle or 0 if failed

result = ZIP_FileOpen(FileName.s[, Append_Method])
	FileName.s = filename with path (*.*, file must exist!)
	Append_Method = #APPEND_STATUS_CREATEAFTER or #APPEND_STATUS_ADDINZIP (optional)
	You can add zipfiles to your exe (sfx) or another zipfile
	
	result = ziphandle or 0 if failed
	
void = ZIP_FileClose(ZipHandle[, Comment.s])
	ZipHandle = handle comes as result of ZIP_FileCreate() or ZIP_FileOpen()
	Comment = string or textfilename (with path) *.txt! (optional)  
	
	no result
	
result = ZIP_FileAdd(ZipHandle, Filename.s, Archive_Filename.s[, Compression[, Callback]])
	ZipHandle = result from ZIP_FileCreate() or ZIP_FileOpen()
	Filename.s = filename with path to add to archive
	Archive_Filename.s = filename with relative path in archive
	Compression = #Z_NO_COMPRESSION or #Z_BEST_SPEED or #Z_BEST_COMPRESSION or #Z_DEFAULT_COMPRESSION (optional)
	Callback = adress of callbackprocedure, Prototyped as: ZIP_PackerCallback(progress)*
		*you can return #ZIP_CANCEL from Callback to cancel
	
	result = #True on success

result = ZIP_MemAdd(ZipHandle, *source, sourceLen, Archive_Filename.s[, Compression[, Callback]])
	ZipHandle = result from ZIP_FileCreate() or ZIP_FileOpen()
	*source = memorypointer
	sourceLen = memorysize in bytes
	Archive_Filename.s = filename with relative path in archive
	Compression = #Z_NO_COMPRESSION or #Z_BEST_SPEED or #Z_BEST_COMPRESSION or #Z_DEFAULT_COMPRESSION (optional)
	Callback = adress of callbackprocedure, Prototyped as: ZIP_PackerCallback(progress)*
		*you can return #ZIP_CANCEL from Callback to cancel
	
	result = #True on success
If you find any bugs, please contact me.
From time to time there will be some increments on this, so any wishes can be told here.

Download

Greetings
Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
dige
Addict
Addict
Posts: 1391
Joined: Wed Apr 30, 2003 8:15 am
Location: Germany
Contact:

Post by dige »

Well done! Thx ts-soft
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Update

many Bugfixes
CHM-Help added
UserLib 32- and 64-Bit added (with source)
(However, you must also decide, either Include or UserLib, both does not go)

Have Fun
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Coolman
Enthusiast
Enthusiast
Posts: 103
Joined: Sat Sep 03, 2005 4:07 pm

Post by Coolman »

ts-soft wrote:Update

many Bugfixes
CHM-Help added
UserLib 32- and 64-Bit added (with source)
(However, you must also decide, either Include or UserLib, both does not go)

Have Fun
Thank you 8), especially for the source code, I no longer uses the libs with PureBasic not to be blocked later in the release of new versions...
*** Excuse my bad English, I uses has translating program ***
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

thanks ts-soft yet another great contribution.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Update

resident for x64 fixed
New function: ZIP_DirAdd((ZipHandle, Directory.s [, Compression [, Callback]])
code stripped-down
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: minizip lib

Post by jassing »

I tried using the minizip lib
I get errors from polink about not being able to resolve functions.
any idea what I did wrong?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: minizip lib

Post by ts-soft »

The userlib is outdated, use the include or tailibite it by yourself :wink:

Greetings - Thomas
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: minizip lib

Post by jassing »

Sadly, I tried that - complained about fill_fopen_filefunc()
thanks for the info tho.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: minizip lib

Post by ts-soft »

You haven't put the static lib in the right dir!
For x86:

Code: Select all

Debug #PB_Compiler_Home + "PureLibraries\Windows\Libraries\minizip_x86.lib"
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: minizip lib

Post by jassing »

ts-soft wrote:You haven't put the static lib in the right dir!
For x86:

Code: Select all

Debug #PB_Compiler_Home + "PureLibraries\Windows\Libraries\minizip_x86.lib"

D'oh! Worse than that - I accidentally removed it trying to "cleanup" ... Thought I didn't need it if I used the source.

thanks
-j
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Error if Filesize = 0

Post by jassing »

I found an error, if the filesize is zero - you end up with a divide by zero error:

In MiniZip_Include.pb

Image

Code: Select all

  If in_filesize <> 0 ; jAssing got divide by zero error in_filesize
    divider = 100 / in_filesize
  Else
    divider = 0
  EndIf
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: minizip lib - Delete file in zip?

Post by jassing »

Any chance someone has code to delete a file from w/in the zip file?
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: minizip lib - Delete file in zip?

Post by ts-soft »

jassing wrote:Any chance someone has code to delete a file from w/in the zip file?
The only way with this lib is to unpack and repack. The static lib doesn't support this.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: minizip lib

Post by jassing »

Thank you for the info...
Post Reply