Page 1 of 1

Zip Extraction for PureAV

Posted: Mon Jun 19, 2006 4:13 pm
by Inf0Byt3
Hi! PureAV is frowing up really nice, but I got stuck really bad and this annoys me extremely. I managed to do all I had to do except the unzipping part. I cannot use PureZIP (from Gnozal) because it's critical to use the threadsafe lib :(. The next step was to try to use Num3's Zlib procedures, but it does not work ok. Can somebody please help me a bit with a simple unzipping example and what lib to use because I'm loosing my mind! I need a simple example, to decompress an archive. Something like this:

Code: Select all

 ReadArchive
  if it's good
   loop
    extract file
    debug path to extracted file
    delete file
   next
  else 
   raise error
  endif
 closearchive
Please help, I haven't sleep in 16 hours :x .

Posted: Tue Jun 20, 2006 11:02 am
by gnozal
I have build a THREADSAFE version of PureZIP ; it should compile in /Thread mode (and only in /Thread mode).
Could you test it ?

Link (only lib) : http://people.freenet.de/gnozal/PureZIP_TS.zip

I've added a /THRD option to Tailbite.

Posted: Tue Jun 20, 2006 11:28 am
by Inf0Byt3
Yes, of course :D. I'll post here the results.

Posted: Tue Jun 20, 2006 2:03 pm
by Inf0Byt3
Hi! I tested it a bit and the decompression part works flawlessly, but I can't say the same thing about the compression procedures. Here is a screenshot with the errors.

[Image removed]

Posted: Tue Jun 20, 2006 4:11 pm
by gnozal
I think you got this error because you used the PureZIP threadsafe version without ThreadSafe enabled. Both PureZIP versions are incompatible ; I suggest to use the subsystems.

I tried the following :
. PureZIP standard version in \PureLibraries\UserLibraries\
. PureZIP threadsafe version in \SubSystems\Gnozal_TS\PureLibraries\

Compile a test program (compression and decompression) with jaPBe V3 :
- ThreadSafe disabled ; Subsystems : none ===> OK
- ThreadSafe enabled ; Subsystems : Gnozal_TS ===> OK
- ThreadSafe disabled ; Subsystems : Gnozal_TS : none ===> 8 polink errors (like your screen capture)
- ThreadSafe enabled ; Subsystems : none ===> 1 polink error '_PB_StringBasePosition'

Test program code :

Code: Select all

Procedure PureZIP_CallbackForTest(File.s, PerCent.f)
  Debug StrF(PerCent, 2) + "%"
EndProcedure
;
myFileinfo.PureZIP_FileInfo
PureZIP_SetCallback(@PureZIP_CallbackForTest())
;
; ---------------------------------------------------------------
;
MyZIP.s = "C:\PureBasic400\Program\PureZIP\test.zip"
MyFilesToZIP.s = "C:\PureBasic400\Program\*.pb"
MyZIPOutPut.s = "C:\PureBasic400\Program\PureZIP\output\"
; Create archive
Debug PureZIP_AddFiles(MyZIP, MyFilesToZIP, #PureZIP_StorePathAbsolute, #PureZIP_Recursive)
; Extract files from archive
Debug PureZIP_ExtractFiles(MyZIP, "*.*", MyZIPOutPut, #True)
; Count files in archive
Debug PureZIP_GetFileCount(MyZIP)
; Add memory bank to archive
Debug PureZIP_AddMemory(MyZIP, "MemoryTest.txt", @MyZIP, Len(MyZIP))
; On file more in archive :
Debug PureZIP_GetFileCount(MyZIP)
; Get files information
For i = 0 To PureZIP_GetFileCount(MyZIP) - 1 
  Debug PureZIP_GetFileInfo(MyZIP,i , @myFileinfo)
  Debug "Number " + Str(i)
  Debug "Filename: " + myFileinfo\FileName
  Debug "Compressed Size: " + Str(myFileinfo\CompressedSize)
  Debug "Uncompressed Size: "+ Str(myFileinfo\unCompressedSize)
  Debug "--------------"
  ; FILE DATE --------------
  ; IMPORTANT : tmu_date\tm_mon  = [0 - 11] : you have to add 1 to tm_mon to get the correct month
  Debug "Last Modification Date : " + Str(myFileinfo\tmu_date\tm_mday) + "/" + Str(myFileinfo\tmu_date\tm_mon + 1) + "/" + Str(myFileinfo\tmu_date\tm_year) + " " + Str(myFileinfo\tmu_date\tm_hour) + ":" + Str(myFileinfo\tmu_date\tm_min) + ":" + Str(myFileinfo\tmu_date\tm_sec)
  ; ------------------------
Next
; Find file in archive
Debug PureZIP_FindFile(MyZIP, "MemoryTest.txt")
; Extract file to memory
MyTEST.s = "0123456789001234567890012345678900123456789001234567890"
Debug PureZIP_ExtractMemory(MyZIP, 21, @MyTEST, Len(MyTEST))
Debug Left(MyTEST, 47)

Posted: Tue Jun 20, 2006 5:05 pm
by Inf0Byt3
You were right, I thought I turned the option on :? ... However, it works prefectly. Thank you for all the help.

Posted: Tue Jun 20, 2006 5:25 pm
by gnozal
Inf0Byt3 wrote:You were right, I thought I turned the option on :? ... However, it works prefectly. Thank you for all the help.
Thanks !
Please test it well ...
If it is reliable, I will provide a threadsafe version for all my libs, using the subsystem trick.

Note to the Purebasic team : this subsystem trick does not work if the threadsafe user library is placed in '\SubSystems\Gnozal_TS\PureLibraries\UserLibraries' ; it has to be in '\SubSystems\Gnozal_TS\PureLibraries\'.

Posted: Tue Jun 20, 2006 5:46 pm
by Inf0Byt3
I'll test it as much as I can. I allready integred it in PureSFX and it works perfectly, and now PureAV can scan in ZIP archives too 8) . Whohooo!