Originally Posted by
lassad
Thanks for reply,
I have seen that there is a module in thinbasic wich is called Zlib. but it does not extract files to memory , and it does not handle password protected zip files.
In other languages as Purebasic for example : there is a module called PUREZIP, it s a very useful module in this case.
Can someone make a wrapper for thinbasic?
Hi Lassad,
a string in thinBasic is a powerful dynamic memory area. You can get a pointer to string data using STRPTR function.
Otherwise it is very easy to get a heap memory allocation using thinBasic Heap functions.
An example. You can use test data you can find into \SampleScripts\zLib\
Here we extract from a known zip file a known file name stored into a subdirectory inside the ZIP file
'----------------------------------------------------------------------------- '-----------------------------------------------------------------------------
uses "ZLib"
Dim sBuffer As String
Dim ZIPFileName As String
Double T1 = Timer
ZIPFileName = APP_ScriptPath & "TestFolder\ZipFiles.tBasic.ZIP"
sBuffer = ZLib_ExtractToString(ZIPFileName, "Data\ZipFiles.tBasic.UZIP.TXT")
Double T2 = Timer
If sBuffer <> "" Then
MsgBox 0, "File Found. Buffer is " & Len(sBuffer) & " bytes." & $CRLF &
"Time taken To Extract: " & Format$(T2-T1, "#0.000")
Else
MsgBox 0, "File not found in ZIP"
End If
The above example extract into a string buffer 2.8 MB of data in 0.012 seconds on my PC so it is quite fast.
Once you have a string buffer, you can get a pointer to it using STRPTR
Long pData = StrPtr(sBuffer)
or you can store the buffer into a Heap returning Heap memory pointer
Long pData = HEAP_AllocByStr(sBuffer)
If you give more info on how you think to use compressed data, I can see what I can do more.
Regarding password protected files, you are right: there is no any function working on password protected zip files.
I will see what I can do to add something, maybe this can be useful to others.
Ciao
Eros
Bookmarks