PureZIP library : ZIP / UNZIP files

All PureFORM, JaPBe, Libs and useful code maintained by gnozal

Moderator: gnozal

QuimV
Enthusiast
Enthusiast
Posts: 337
Joined: Mon May 29, 2006 11:29 am
Location: BARCELONA - SPAIN

Post by QuimV »

Hi,

I'm using PB4.3 and when I execute the next code with the "create Threadsafe executable" flag activated, i get an error message.

Code: Select all

MyZIP.s = "c:\tmp\test.zip"
MyFilesToZIP.s = "c:\tmp\test.pb"
MyZIPOutPut.s = "c:\tmp\"
; 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)
Error Message:
POLINK: error: Unresolved external symbol '_PB_StringBasePosition'.

What am I doing wrong?

Thanks in advanced
QuimV
drgolf
Enthusiast
Enthusiast
Posts: 106
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

Post by drgolf »

Compiler options, Subsystems :

UserLibThreadSafe
UserLibUnicode
UserLibUnicodeThreadSafe
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

drgolf wrote:Compiler options, Subsystems :
UserLibThreadSafe
UserLibUnicode
UserLibUnicodeThreadSafe
Exactly.
PureZIP.chm wrote:This library exists in several versions :
- the standard version, located in %Purebasic%\PureLibraries\UserLibraries\ ;
- the thread-safe version, located in %Purebasic%\SubSystems\UserLibThreadSafe\PureLibraries\ .
- the unicode version, located in %Purebasic%\SubSystems\UserLibUnicode\PureLibraries\ .
- the unicode + thread-safe version, located in %Purebasic%\SubSystems\UserLibunicodeThreadSafe\PureLibraries\ .
In order to use this library in thread-safe mode (compiler option /THREAD), you have to enable the subsystem 'UserLibThreadSafe'
in the PB IDE, or add '/SUBSYSTEM UserLibThreadSafe' to the PBCompiler arguments. In jaPBe, do nothing : it will automatically
enable the 'UserLibThreadSafe' subsystem to use the threadsafe versions of the installed userlibraries.
It's the same logic for unicode and unicode + thread-safe modes.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Hi gnozal.

I maybe found a small problem with you zip userlib.

If I run the following code on my vista 64 Bot System (using PB x86 PB compiler) I always get a "BING!" sound if I click on an item inside the listview.

Sure, I don't use and ZIP command in this small snippet, but the problem does not occure if I remove the userlib from PB (and I only have installed your zip lib!).

Need to compile with Unicode + ThreadSave and WITHOUT XP Skinning support. If skinning support is enabled the problem does NOT occur.

So I believe its a problem with your lib, but maybe this can be a PB bug too, it can not proof. maybe you have an idea and confirm?

Code: Select all

  #Main = 0
  #MDIChild = 1
  If OpenWindow(#Main, 0, 0, 400, 300, "MDIGadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget)
    If CreateMenu(#Main, WindowID(#Main))
      MenuTitle("Menu index 0")
      MenuTitle("MDI windows menu")
        MenuItem(0, "self created item")
        MenuItem(1, "self created item")
        
      MDIGadget(0, 0, 0, 0, 0, 1, 2, #PB_MDI_AutoSize)
        AddGadgetItem(0, #MDIChild, "Child-Fenster")

        AddGadgetItem(idMDI_Main,#PB_Any,"zugzuuz")
        tt=ListIconGadget(#PB_Any,0,0,200,200,"zgu",100)
        AddGadgetItem(tt,-1,"gzugugzu")


          ; add gadgets here...
      UseGadgetList(WindowID(#Main)) ; wir gehen zurück zur Gadgetliste des Hauptfensters
    EndIf
    Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
  EndIf
Thanks!
Tranquil
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Tranquil wrote:Hi gnozal.
I maybe found a small problem with you zip userlib.
If I run the following code on my vista 64 Bot System (using PB x86 PB compiler) I always get a "BING!" sound if I click on an item inside the listview.
After the beep on Windows 7, the bing with Vista 64 :shock:
Do I understand correctly : the problem occurs even if you don't use PureZIP in your code ?
Is there any sign of ZLIB in the final EXE ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Yes, the problem occures even if I dont use your ZIP commands.

If you want I can upload the same snipped that Ive posted here so that you can take a look on the exe.

Didnt know that this problem was also on Windows 7. As I wrote, it only occurs when XP Skinning is disabled.

EDIT:
http://rapidshare.com/files/223602597/Bing.exe

Thats my compiled version that makes shows the problem. Maybe its a PB bug? Dont know.
Tranquil
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Tranquil wrote:Yes, the problem occures even if I dont use your ZIP commands.
If you want I can upload the same snipped that Ive posted here so that you can take a look on the exe.
ZLIB doesn't seem included in the EXE.
I really have no idea what the problem could be ... if PureZIP isn't used, how could it influence the compiled exe :shock: ?

NB : if I compile your code with Unicode + ThreadSave and WITHOUT XP Skinning support (jaPBe V3 + PB4.30 x86 + installed PureZIP on NT4), I get a different EXE : http://rapidshare.com/files/223612425/bing2.zip.html ; could you test it ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

That is mysterious. You exe also plays the BING sound on every click on the lists item.

EDIT: In my compiled exe I also have onError support enabled. Think thats the reason why it is a bit bigger then yours.
Tranquil
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

Me again:

Is it possible to send userdatas to a progression callback? I'm using many threads in my code, maybe there are more then one compression at a time with more then one progressbar. So I need to be able to send some userdatas to the progression callback to handle these. Is it possible to add this?

The Callback-Procedure then needs to be extended by a user value. (a pointer would be great)

Then those both commands needs to be enhanced with an optional parameter which holds the userdata that is send to the callback.

- PureZIP_ExtractFiles()
- PureZIP_AddFiles()

Edit:
And now I have another problem. If I add files to my archive using PureZIP_Archive_Create & #APPEND_STATUS_ADDINZIP in conjunction with PureZIP_Archive_Compress OR just PureZIP_AddFiles() I cant see my files after that with PureZip. If I use TotalCommander I can see my files. Ö.ö

Thanks for your great work!
Tranquil
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Tranquil wrote:Is it possible to send userdatas to a progression callback? Is it possible to add this?
It is possible, but it will break any existing code using callbacks because of this extra parameter.

I have uploaded a quickfix for you : http://freenet-homepage.de/gnozal/PureZIP_V2_430.zip [libs for PB4.30 only]. Compression / decompression functions now expect an optional UserParam.
This UserParam is mandatory in the callback functions.

Code: Select all

Procedure MyCallback(FileName.s, Progression.f, UserParam.l)
	; FileName : current processed file (if applicable)
	; UserParam : some (optional) user parameter
	; Progression : progression percentage
	ProcedureReturn #False                  
	; ProcedureReturn #True to stop the compression
EndProcedure
Could you test it ?
Tranquil wrote:And now I have another problem. If I add files to my archive using PureZIP_Archive_Create & #APPEND_STATUS_ADDINZIP in conjunction with PureZIP_Archive_Compress OR just PureZIP_AddFiles() I cant see my files after that with PureZip. If I use TotalCommander I can see my files.
Hmm...
This code works here :

Code: Select all

; Create new zip
If PureZIP_Archive_Create("c:\purebasic430\program\test.zip", #APPEND_STATUS_CREATE)
  PureZIP_Archive_Compress("c:\PureBasic430\Help\PureWCX.chm", #False)
  PureZIP_Archive_Compress("c:\PureBasic430\Help\PureRESIZE.chm", #False)
  PureZIP_Archive_Close()
EndIf
; Append files to existing zip
If PureZIP_Archive_Create("c:\purebasic430\program\test.zip", #APPEND_STATUS_ADDINZIP)
  PureZIP_Archive_Compress("c:\PureBasic430\Help\PureCOLOR.chm", #False)
  PureZIP_Archive_Compress("c:\PureBasic430\Help\PureCAB.chm", #False)
  PureZIP_Archive_Close()
EndIf
; List zip content
myFileinfo.PureZIP_FileInfo
If PureZIP_Archive_Read("c:\purebasic430\program\test.zip")
  ReturnValue.l = PureZIP_Archive_FindFirst() = #UNZ_OK
  While ReturnValue = #UNZ_OK 
    PureZIP_Archive_FileInfo(@myFileinfo)
    Debug "Filename: " + myFileinfo\FileName
    Debug "Compressed Size: " + Str(myFileinfo\CompressedSize)
    Debug "Uncompressed Size: "+ Str(myFileinfo\unCompressedSize)
    ReturnValue = PureZIP_Archive_FindNext()
  Wend
  PureZIP_Archive_Close()
EndIf
PureZIP sees all 4 archived files.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post by Tranquil »

You are great gnozal!!! I will try asap! Thanks a lot!
Tranquil
endo
Enthusiast
Enthusiast
Posts: 141
Joined: Fri Apr 30, 2004 10:44 pm
Location: Turkiye (istanbul)
Contact:

Post by endo »

hi, PureZIP_ExtractFiles returns zero even it extract files correctly? I'm using the latest purezip from
I have uploaded a quickfix for you : http://freenet-homepage.de/gnozal/PureZIP_V2_430.zip [libs for PB4.30 only].
with PB 4.30 registered, no multitreaded, no unicode.
extracted files are ok.
-= endo (registered user of purebasic since 98) =-
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

endo wrote:hi, PureZIP_ExtractFiles returns zero even it extract files correctly? I'm using the latest purezip from
I have uploaded a quickfix for you : http://freenet-homepage.de/gnozal/PureZIP_V2_430.zip [libs for PB4.30 only].
with PB 4.30 registered, no multitreaded, no unicode.
extracted files are ok.
Oops, forgot some ProcedureReturn in this build ... fixing ...
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
endo
Enthusiast
Enthusiast
Posts: 141
Joined: Fri Apr 30, 2004 10:44 pm
Location: Turkiye (istanbul)
Contact:

Post by endo »

gnozal wrote:
endo wrote:hi, PureZIP_ExtractFiles returns zero even it extract files correctly? I'm using the latest purezip from
I have uploaded a quickfix for you : http://freenet-homepage.de/gnozal/PureZIP_V2_430.zip [libs for PB4.30 only].
with PB 4.30 registered, no multitreaded, no unicode.
extracted files are ok.
Oops, forgot some ProcedureReturn in this build ... fixing ...
wow, u r fast! I'm waiting thx :)
-= endo (registered user of purebasic since 98) =-
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

endo wrote:wow, u r fast! I'm waiting thx :)
... should be fixed (same link).
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply