PureZIP library : ZIP / UNZIP files

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

Moderator: gnozal

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

Post by gnozal »

Micko wrote:Gnozal can purezip support an other archive format ? like ace, tar... or just zip archive
Only classic ZIP archive.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

I seem to have a problem stopping the compression. I use PureZIP_AddFiles and in the Compression callback even I return #True it won't stop. I read in the manual that the returned value is only for PureZIP_Archive_Compress() and PureZIP_Archive_Extract(). How can I stop it from a PureZIP_AddFiles command?
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Inf0Byt3 wrote:I seem to have a problem stopping the compression. I use PureZIP_AddFiles and in the Compression callback even I return #True it won't stop. I read in the manual that the returned value is only for PureZIP_Archive_Compress() and PureZIP_Archive_Extract(). How can I stop it from a PureZIP_AddFiles command?
Currently, you can't.
If you want full control, use the PureZIP_Archive_*() functions.
The other functions are just to make the programmer's life easier.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Could you please implement a stop signal like the other functions? If you don't have time i'll just create a recursive runner and pack the files on-the-way.

[Edit]
I followed your advice and did it :). Thanks.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

Hello Gnozal,

I try to create a complete CallBackC for all Files in one process. Example:

Code: Select all


Global All_Percent.f

...
...
...

Procedure.l PureZIP_CallbackC(File.s, PerCent.f)

All_Percent + PerCent
SetGadgetState(ProgressBar, All_Percent)

Event=WindowEvent()

If Event=#PB_Event_Gadget
  If EventGadget()=31
    DisableGadget(31,1)
    SetWindowTitle(1,"Process Breaked ... Please Wait!")
    ArcBreak=#True
  EndIf
EndIf

ProcedureReturn ArcBreak

EndProcedure
I have set the ProgressBar's maximum attribute (#PB_ProgressBar_Maximum) to 100 * NumFiles.l

For Example:
ProgressBarGadget(30, 22, 23, 376, 26, 0, 100 * NumFiles)

But it doesn't work. I have set a Debug PerCent.f in the Procedure and see now that when a File is done,
the CallBack is called anymore when the PerCent.f value is already on 100.0 %. (Sometimes called up to 10 x or more)
It is possible to fix it ? I use PureZIP 1.92.
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Hi! Please check your progressbar gadget code. Usually the gadget editor makes the minimum 0 and the maximum 10, not 100 as you expect. It took some time to understand here too.

[Edit]
Sorry i misread your post. Please ignore.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AL90 wrote:I try to create a complete CallBackC for all Files in one process.
....
I assume you use PureZIP_AddFiles() ?
The compression callback is only for the (de)compression process. PerCent.f is set to zero before each compression and to 100 when the compression is completed.
Use the progression callback to display the 'file progression', or use your own file counter.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

gnozal wrote:I assume you use PureZIP_AddFiles() ?
No. I use PureZIP_Archive_Compress
The compression callback is only for the (de)compression process.
Yes, that is it what I want to use (TotalBytes of all Files for view in a single ProgressBar Gadget)
PerCent.f is set to zero before each compression and to 100 when the compression is completed.
Yes I known. But here is my problem. The value 100.0 will return
more than 1 x, after the Compression from a single file. Sometimes displays
the Debugger up to 10 x 100.0 (%) in the CallbackC Procedure.
Use the progression callback to display the 'file progression', or use your own file counter.
How I say above, my think is a CallBackC to calculate
All Bytes of Files added in one variable for use in a Status-Panel with only one ProgressBar Gadget.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

AL90 wrote:But here is my problem. The value 100.0 will return more than 1 x, after the Compression from a single file. Sometimes displays the Debugger up to 10 x 100.0 (%) in the CallbackC Procedure.
It's a precision problem I think.
The last compression progression values may be 99.9997, 99.9998, 99.9999 ... all rounded to 100.0.
And PureZIP sends an extra '100.0' value when the compression is finished.
This should not be not a problem for displaying a progression bar.
AL90 wrote:
Use the progression callback to display the 'file progression', or use your own file counter.
How I say above, my think is a CallBackC to calculate
All Bytes of Files added in one variable for use in a Status-Panel with only one ProgressBar Gadget.
I understand that, but you can still use your own counter : each time you compress a file, increment your counter, so your progression will be PerCent.f * MyOwnCounter.l
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
AL90
Enthusiast
Enthusiast
Posts: 217
Joined: Fri Sep 16, 2005 7:47 pm
Location: Germany
Contact:

Post by AL90 »

gnozal wrote:I understand that, but you can still use your own counter : each time you compress a file, increment your counter, so your progression will be PerCent.f * MyOwnCounter.l
Ok I will see what for a solution I can use. Thanks for the suggestion. :wink:
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Gnozal, how can I create the archive with PureZip_Archive commands and have the paths in the archive relative? I can't use PureZIP_AddFiles() because I want to be able to stop it and PureZIP_Archive_Compress() can only store full path or none :(. Is there a way to do this?
StorePath values :
#TRUE : the complete filename (including path) is stored ;
#FALSE : only filename is stored.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Inf0Byt3 wrote:Gnozal, how can I create the archive with PureZip_Archive commands and have the paths in the archive relative? I can't use PureZIP_AddFiles() because I want to be able to stop it and PureZIP_Archive_Compress() can only store full path or none :(. Is there a way to do this?
Like this ?

Code: Select all

; Store relative to base directory

BaseDirectory.s = "c:\Purebasic400"

SetCurrentDirectory(BaseDirectory)

If PureZIP_Archive_Create("c:\Test.zip", #APPEND_STATUS_CREATE)
  
  FileToAdd.s = "c:\Purebasic400\Compilers\APIFunctionListing.txt"
  RelativeFilePath.s = RemoveString(FileToAdd, BaseDirectory, 1)
  
  PureZIP_Archive_Compress(RelativeFilePath, #True)
  
  PureZIP_Archive_Close()
EndIf
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

D'oh!

Thanks!
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Nope, that's not quite what i needed. I need to simulate PureZIP_AddFiles as I said earlyer but i cannot do that if the files are stored either with full path or none. Could you please add a #PureZIP_Path_Relative to the PureZIP_Archive_Compress command?
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Inf0Byt3 wrote:Nope, that's not quite what i needed. I need to simulate PureZIP_AddFiles as I said earlyer but i cannot do that if the files are stored either with full path or none.
What is wrong with my example, it's the same as #PureZIP_StorePathRelative ?
In test.zip, the file is stored as 'Compilers/APIFunctionListing.txt', wich is the path relative to 'c:\Purebasic400\' for 'c:\Purebasic400\Compilers\APIFunctionListing.txt'.
Inf0Byt3 wrote:Could you please add a #PureZIP_Path_Relative to the PureZIP_Archive_Compress command?
I cannot 'just' add a #PureZIP_StorePathRelative flag : PureZIP_Archive_Compress() does not know the base directory, only the path of the file you want to compress, so how should the function store a path relative to base directory ?
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Post Reply