Posted: Fri Jun 06, 2008 3:12 pm
@gnozal, is it safe to use the current lib with PB4.20 final?
http://www.purebasic.com
https://www.purebasic.fr/english/
If it wasn't it should be nowInf0Byt3 wrote:@gnozal, is it safe to use the current lib with PB4.20 final?
Code: Select all
MyFolder\ZippedFile1.txt
MyFolder\ZippedFile2.txt
This function is a simple wrapper to the ZLIB unzGetGlobalInfo() function. It returns the unz_global_info\number_entry value, wich is the "total number of entries in the central directory of the zip archive".PB wrote:Just testing PureZIP for the first time, and I noticed that sometimes it reports the number of files +1 by mistake, if the archive has a folder in it
Code: Select all
myFileinfo.PureZIP_FileInfo
If PureZIP_Archive_Read(MyZIP.s)
ReturnValue.l = PureZIP_Archive_FindFirst() = #UNZ_OK
While ReturnValue = #UNZ_OK
Debug PureZIP_Archive_FileInfo(@myFileinfo)
Debug "Filename: " + myFileinfo\FileName
Debug "Compressed Size: " + Str(myFileinfo\CompressedSize)
Debug "Uncompressed Size: "+ Str(myFileinfo\unCompressedSize)
; etc ... see PureZIP_FileInfo structure members
ReturnValue = PureZIP_Archive_FindNext()
Wend
PureZIP_Archive_Close()
EndIf
Code: Select all
EnableExplicit
Import "ZlibStatic.lib"
gzclose(a.l) As "_gzclose@4"
gzopen(a.l,b.l) As "_gzopen@8"
gzread(a.l,b.l,c.l) As "_gzread@12"
EndImport
Procedure.l gzUncompress(*in,inlen.l)
Define tempPath.s,lg.l,filehdl.l,length.l,*out,tempFILENAME.s,zerr.l
;Create a temporary file to be able to use gzopen
tempPath=Space(#MAX_PATH)
lg=GetTempPath_(#MAX_PATH,tempPATH)
tempPath=Left(tempPath,lg)
tempFILENAME.s=Space(#MAX_PATH)
lg=GetTempFileName_(@tempPath,"TMP", 0, @tempFilename)
OpenFile(1,tempFilename)
WriteData(1,*in,inlen)
CloseFile(1)
;The real decoding starts here
fileHdl = gzopen(@tempFilename, @"rb")
length=PeekL(*in+inlen-4)
*out=AllocateMemory(length)
gzread(fileHdl,*out,length)
zerr=gzclose(fileHdl)
DeleteFile(tempfilename)
FreeMemory(*in)
ProcedureReturn *out
EndProcedure
Procedure GetContent() ;concatenates a series of strings of a data section
;and base64 decodes it
Define temp.s, cont.s,*out,lg.l
Repeat
Read temp
cont=cont+temp
Until temp=""
lg=Len(cont)
*out=AllocateMemory(lg)
lg=Base64Decoder(@cont,lg,*out,lg)
*out=ReAllocateMemory(*out,lg)
ProcedureReturn *out
EndProcedure
Define lg.l,*content,*in
Restore gzfile1
*content=getcontent()
lg=MemorySize(*content)
*content=gzUncompress(*content,lg)
Debug PeekS(*content,-1,#PB_Ascii)
FreeMemory(*content)
Restore gzfile2
*content=getcontent()
lg=MemorySize(*content)
*content=gzUncompress(*content,lg)
Debug PeekS(*content,-1,#PB_Ascii)
FreeMemory(*content)
Delay(5000)
DataSection
gzfile1:
Data.s "H4sICOSCsEgAAHRlc3QyLnR4dAANi7sRwkAMBXNm6OFVQBdkNPHQyUYgn+Bs83G3hAQEDJnHgS"
Data.s "/a3WD3jrt6TOjGIvZxtoGT5TRDovsSjbpNEJZk7oEXLvaw3XZzIMTaRX/EEMIjoY6ez2j+GUmH8"
Data.s "u4rHFe65tuoNaqfWdcVNlmb93MAAAA="
Data.s ""
gzfile2:
Data.s "H4sICJ8/sEgAAHRlc3QzLnR4dADVVd9v2jAQfk6l/g9e+tBQlARKmTpCkLZuD93DNmnTXqo+GO"
Data.s "eSuDh2ZjsUNPV/n21SfnSa1vKCCgg55+++++58voTh5PhoHCu9ZGBXikhaa8QwLxpcQOp/xnP83"
Data.s "Rl9pJe1sWhY6HjbrCRJ/TsV5w0nVHBQ0Z3yJ4bU7e/Jat3ehOHxkTfHEmmhMfsJXGOOFUrRMEFx"
Data.s "jH81FClAlGeUYI6AId5UIAXKAM1b8MoV1PFRS1VRtUXE4R69lxIvg07iILmQgYXVaS9B9XgnsDF0"
Data.s "ux3028C8LZqb+tYwnbYRT1EXfWmqKcigNsu+5fUe1uHnVNHpPwV45mfLqE0dUUZVzfDymlNCMQucp"
Data.s "8mkYzBWwqowhqJnHa1w5JRTq5yOH+FmvRbt7US/oVZ3JkhTGUtUgP7EwC4/LK+zwCa4AXYi1yJRqyl"
Data.s "xbDQP/iY0lZgyQWannVVIT3e7Dm6L0P7VQlHbKo+OgV5VCaFN9gUovQ1py9tmAosa8+xKMIZrBevN5"
Data.s "P912corYsALXR68QusARmv1lTRMiwhWgdTNoEtvozlmDRgp/eSJx7RRBMtvmOGpxBun4a7T04MwV8Xc"
Data.s "mxdH7+0Tvffcw3fdb7/jCjRGpdZ1COaKz1P/SnBt0OEPMyp8RFZP7cwodcUSREosFeiUKhFeXg7fhX1/"
Data.s "4rgY5TNUSshTn1bYNFVs+4oJ9RFyymk7sIhSPpLAUt8doioBdieTBUx26eJdvusMBBMFJWIvtuc5uO3Na"
Data.s "Dxp+77vzvKeZrocnQ/P64UpaHzWGgZve8ZwFhtECbQo9WhwMXAQb4rJrJCi4VlIjHg5Osndx+7lTGA9Yp"
Data.s "Br+2RVhJjRgq9ND1sCzg8tYHBoARcHEvBqX+Cv44X8B0240m8gCQAA"
Data.s ""
I have not compiled the static library (don't remember from where I got it) nor have I designed the code.fizban wrote:... In the following example, I have base64 encoded a couple of files in the data section so that they are easier to post here. The first one works. The second doesn't, with an invalid memory access. Any ideas why?...
Must be a proxy / cache issue : I just downloaded the lib, I get 23f46a8a543fea47eacdcc0537ae1f04 for ZlibStatic.libfizban wrote:Either it is the same library or I am downloading a proxied version. Winmerge reports that the lib file is identical as the I was using. MD5 of the lib file is D1AC5A0F0B2BE7349F76408D988A19F4
Nope. Iirc, it comes from http://www.winimage.com/zLibDll/fizban wrote:Did you compile this one yourself?