Page 1 of 2

minizip lib

Posted: Mon Feb 16, 2009 11:04 pm
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

Posted: Mon Feb 23, 2009 7:50 am
by dige
Well done! Thx ts-soft

Posted: Wed Feb 25, 2009 1:10 pm
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

Posted: Wed Feb 25, 2009 4:41 pm
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...

Posted: Wed Feb 25, 2009 8:48 pm
by idle
thanks ts-soft yet another great contribution.

Posted: Thu Feb 26, 2009 11:31 am
by ts-soft
Update

resident for x64 fixed
New function: ZIP_DirAdd((ZipHandle, Directory.s [, Compression [, Callback]])
code stripped-down

Re: minizip lib

Posted: Fri Jan 28, 2011 12:24 am
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?

Re: minizip lib

Posted: Fri Jan 28, 2011 12:39 am
by ts-soft
The userlib is outdated, use the include or tailibite it by yourself :wink:

Greetings - Thomas

Re: minizip lib

Posted: Fri Jan 28, 2011 1:14 am
by jassing
Sadly, I tried that - complained about fill_fopen_filefunc()
thanks for the info tho.

Re: minizip lib

Posted: Fri Jan 28, 2011 1:29 am
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"

Re: minizip lib

Posted: Fri Jan 28, 2011 1:36 am
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

Error if Filesize = 0

Posted: Fri Jan 28, 2011 6:30 am
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

Re: minizip lib - Delete file in zip?

Posted: Fri Jan 28, 2011 7:00 pm
by jassing
Any chance someone has code to delete a file from w/in the zip file?

Re: minizip lib - Delete file in zip?

Posted: Fri Jan 28, 2011 7:05 pm
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.

Re: minizip lib

Posted: Tue Feb 01, 2011 3:19 pm
by jassing
Thank you for the info...