******************************************************************** * Description...... : Archive * Calling Samples...: * Parameter List....: tcItemList, tcZipFile, tlDeleteOriginal * Created by .......: Nadya Nosonovsky with Mark's comments * Modified by.......: Nadya Nosonovsky 04/27/2001 09:47:22 AM ******************************************************************** lparameters tcItemList, tcZipFile, tlDeleteOriginal *!* vartype tests should always come first. if the parameter *!* passed is not a character data type, the EMPTY() tests *!* can give you an error. if vartype(m.tcItemList)<>'C' or empty(m.tcItemList) && invalid parameter return .f. endif if vartype(m.tcZipFile)<>'C' or empty(m.tcZipFile) && invalid parameter return .f. endif local oZip oZip = newobject("DynaZip", "DynaZip.FXP") with oZip .cZip_ZipFile = m.tcZipFile .cZip_ItemList = m.tcItemList * .lZip_Recurse = .f. && not needed because this is the default value .lZip_Quiet = .t. .lZip_DeleteOriginal = m.tlDeleteOriginal && Delete the original file && ARE YOU SURE YOU REALLY WANT TO DO THIS??? && If you really want to do this, then you have to follow the && comments on this property that are provided in the DynaZip.prg .lZip_NoDirNames = .t. * .lUnz_NoDirItems = .t. && this is an unzip option .lZip_NoDirEntries = .t. * .lZip_CryptFlag = .f. && not needed because this is the default value * .lZip_CryptCode = "" && not needed because this is the default value * .dz_Zip_Function = 4 && not needed. this is taken care of in the ZipAdd method * .lUnz_OverWrite = .t. && this is an unzip option * .lUSO_OverWrite_RO = .t. && this is an unzip option .lZSO_MinorCancel = .t. .lZSO_ExternalProg = .t. .lZSO_ExtProgCancel = .t. .cZip_ExtProgTitle = "Adding files to archive "+m.tcZipFile * .lZip_NoMsgs = .t. llSuccess = .ZipAdd() .release() endwith release oZip return m.llSuccessAnd here for extracting:
******************************************************************** * Description.......: Extract * Calling Samples...: * Parameter List....: tcDataDir, tcZipFile * Created by .......: Nadya Nosonovsky with Mark's comments * Modified by.......: Nadya Nosonovsky 04/27/2001 09:50:28 AM ******************************************************************** lparameters tcDataDir, tcZipFile *!* vartype tests should always come first. if the parameter *!* passed is not a character data type, the EMPTY() tests *!* can give you an error. if vartype(m.tcDataDir)<>'C' or empty(m.tcDataDir) && invalid parameter return .f. endif if vartype(m.tcZipFile)<>'C' or empty(m.tcZipFile) && invalid parameter return .f. endif tcZipFile = alltrim(m.tcZipFile) if not file(m.tcZipFile) && invalid file or invalid path to file return .f. endif local oZip oZip = newobject("DynaZip", "DynaZip.FXP") with oZip .cUnz_ZipFile = m.tcZipFile .cUnz_FileSpec = "*.*" .cUnz_Destination = m.tcDataDir * .lUnz_OverWrite = .t. && not needed. these are the default values .lUnz_Quiet = .t. * .lUnz_NoDirNames = .t. && not needed. these are the default values * .lUnz_Recurse = .f. && not needed. these are the default values * .lUnz_NoDirItems = .t. && not needed. these are the default values * .lUnz_CryptFlag = .f. && not needed. these are the default values * .lUnz_CryptCode = "" && not needed. these are the default values * .dz_Unz_Function = 8 && not needed. handled by UnzExtract method .lUSO_OverWrite_RO = .t. .lUSO_MinorCancel = .t. .lUSO_ExternalProg = .t. .lUSO_ExtProgCancel = .t. .cUnz_ExtProgTitle = "Extracting files from "+m.tcZipFile .lUnz_NoMsgs = .t. llSuccess = .UnzExtract() .release() endwith release oZip return m.llSuccess