Zlib Help

BlitzMax Forums/BlitzMax Programming/Zlib Help

Caton(Posted 2016) [#1]
Zlib Extract all files in current dir example? I been looking around all I see is gzip but no docs for zlib just compress and decompress.


Derron(Posted 2016) [#2]
Search there

-> others had similar issues before
-> eg. use one of the zip-modules available for BlitzMax

combine this with "all files in a directory" (loop through them and do the unzip when it is an archive).



bye
Ron


Caton(Posted 2016) [#3]
I'm asking this because I'm making a update for my game it will extract files and dirs from the zip folder in current game dir


Caton(Posted 2016) [#4]
it says unzOpen not found I have zlib install in bmx ng
Import Pub.ZLib
UnpackZip("date.zip","test.txt")
Function UnpackZip(filename$,filename2$)
	Local result:Int = 0
	Local outStream:TStream = WriteStream(filename2$)
	Local numberOfBytes:Int
	Local data:Byte Ptr
	zipFile = unzOpen(filename$)
	If (zipFile) Then
		result = unzLocateFile( zipFile, filename2$, UNZ_NO_CASE_CHECK )
		
		If ( result = UNZ_OK ) Then
			result = unzOpenCurrentFile( zipFile )
			
			If ( result = UNZ_OK ) Then
			
				Local size = unzGetCurrentFileSize(zipFile)

				data = New Byte Ptr[size]
				numberOfBytes = unzReadCurrentFile (zipFile, data, size )
				
				For i:Int = 1 To size
					WriteByte( outStream, data[i] )
				Next 
				
				CloseStream ( outStream )
				
			End If
		End If
		unzClose( zipFile )	
	End If
End Function