Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Unzip/restore with vfpcompression.fll
Message
From
02/06/2008 00:52:27
Chris Sund
Silhouette Solutions
Utah, United States
 
 
To
01/06/2008 00:33:23
Chris Sund
Silhouette Solutions
Utah, United States
General information
Forum:
Visual FoxPro
Category:
Third party products
Miscellaneous
Thread ID:
01320805
Message ID:
01320874
Views:
22
I was able to determine the file count of the zip. I used the following example to obtain the information necessary to create an unzip progress bar. This in addition to the "cZipObjectName" variable that the vfpcompression.fll uses to determine the current file it's unzipping worked great.

http://www.berezniker.com/content/pages/visual-foxpro/vfp-implementation-getzipcomment-and-getzipfileslist-zip-acrchives


The rough draft of my code looked like this. I will remove the wait window and replace it with a progress bar on a form.
PUBLIC jobject, jcount,lnZipFilecount

lnZipFileCount=0
jobject='XXX'
jcount=0

loZU = NEWOBJECT("ZipUtils", "ZipUtils.fxp")


lnZipFileCount = loZU.GetZipFileCount("C:\sps.zip")

m.lcAppPath = ADDBS(JUSTPATH(SYS(16,0)))

SET DEFAULT TO (m.lcAppPath)
SET LIBRARY TO LOCFILE("vfpcompression.fll")

ZipCallback("MyCallback()") && Start Event Handling - Any Function/Procedure/Method (in scope of course)

?UnzipQuick("C:\sps.zip", "C:\tlp") && unzip contents of Test.zip to C:\



ZipCallback("") && Stop Event Handling
SET LIBRARY TO

*****************************
FUNCTION MyCallback()
*****************************


    *!* Variables below are created on the fly
    *!* by the FLL when the ZipCallback feature is used
    
    *!* Depends on the value of nZipEvent
    ?cZipObjectName && Name of Zip, File, or Folder being processed
    
    IF jobject<>czipObjectName
    jcount=jcount+1
    jobject=czipObjectName
    endif
    
    
    *!* Events that fire MyCallback
    *!* 0 = Open Zip
    *!* 1 = Start Zip/Unzip of File
    *!* 2 = Read/Write File (nZipBytes will contain value of bytes read for event)
    *!* 3 - End Zip/Unzip of File
    *!* 4 - Folder Opened
    *!* 5 - Close Zip
    ?nZipEvent
    
    *!* Number of Bytes read (Event 3)
    ?nZipBytes
    
    && Get a file count in ZIP
    
    
    jtotal=jcount/lnZipFileCount
    jpercentage=jtotal*100
    
    WAIT WINDOW NOWAIT 'Working on ['+czipobjectname+']'+'   '+STR(jpercentage)


ENDFUNC




*******************************
FUNCTION Progress(tnTotalFiles, tnCurrentFile, tcFileName)
*******************************
	LOCAL lnProgressPercent
	m.lnProgressPercent = Round(m.tnCurrentFile/m.tnTotalFiles,0)*100
	*!* hook progress indication in here
	
	
	jv1=m.tnCurrentFile/m.tnTotalFiles
	jv2=jv1*100
	
	WAIT WINDOW NOWAIT jv2
*!*	    backup.progressbar1.value=ROUND(jv2,0)  

*!*	  IF ROUND(jv2,0)=100
*!*	  backup.caption='Backup Files - COMPLETE!'
*!*	  backup.refresh
*!*	  ENDIF
*!*	  
*!*	  backup.progressbar1.refresh
*!*	  
*!*	  

	
ENDFUNC


FUNCTION zipcallback 
FUNCTION unzipquick
The "ZipUtils" function is explained in the link I provided. It's basically a .prg I placed in my project.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform