I also mentioned this in thread184-1695373
But as this in fact has nothing to do with that subject I decided to start a new thread.
I have a path/file naming problem.
Using Azip the actual zip action's syntax is : lnFilesInZip = Azip(.T. ,lcArchiefnaam , lcWhat2Backup)
lnFilesInZip returns the number of files which has been zipped.
lcArchiefnaam is the name of the zipfile
lcWhat2Backup contains the path with the files which must be zipped.
The latter caused my failure.
I always had a relative path <"data\*.*" > to the files and I changed it in a full-path naming.
<"c:\program files\myapp\data\*.*">
But [beginners fault] this may not contain any space in the file name.
The stupid thing: I faced this problem also years ago (problem of 55+ age)
I can't remember how I fixed that.
Any suggestion:
"data\*.*" works fine wheras
"c:\program files\myapp\data\*.*" fails
Any suggestions? I have to update as my data-files can't stay in sub-folder of my app due to win7 restrictions.
As documentation here is the original code of Stephan Darlington
TIA
-Bart
Fo
But as this in fact has nothing to do with that subject I decided to start a new thread.
I have a path/file naming problem.
Using Azip the actual zip action's syntax is : lnFilesInZip = Azip(.T. ,lcArchiefnaam , lcWhat2Backup)
lnFilesInZip returns the number of files which has been zipped.
lcArchiefnaam is the name of the zipfile
lcWhat2Backup contains the path with the files which must be zipped.
The latter caused my failure.
I always had a relative path <"data\*.*" > to the files and I changed it in a full-path naming.
<"c:\program files\myapp\data\*.*">
But [beginners fault] this may not contain any space in the file name.
The stupid thing: I faced this problem also years ago (problem of 55+ age)
I can't remember how I fixed that.
Any suggestion:
"data\*.*" works fine wheras
"c:\program files\myapp\data\*.*" fails
Any suggestions? I have to update as my data-files can't stay in sub-folder of my app due to win7 restrictions.
As documentation here is the original code of Stephan Darlington
Code:
*********************************************************************************************************
* Azip procedure to zip files for Visual FoxPro using the
* AddZip AZIP32.DLL from shareware
* [URL unfurl="true"]http://ourworld.compuserve.com/homepages/Stephen_Darlington/addzip.htm[/URL]
* Requirements: AZIP32.DLL in your Windows\system directory or current directory
*
* USAGE: AZIP(lInitialize, sArchive, sInclFiles[, ZipParams])
*
* Example: AZIP(.T., "ZIPFILE", "*.DBF *.TXT Customer.doc")
*
* PARAMETERS:
*-- lInitialize: .T. first time & Done only once before or when starting file zip - .F. afterward
*- Calling azip() with no params also initializes
*-- sArchive: Archive FileName with extension - Example "C:\THISFILE.ZIP"
*-- sInclFiles: String repr. file(s) to include
*-- Example1 "D:\CUSTDATA.DBF"
*-- Example2 "C:\CUSTOMER.DBF D:\*.TXT D:\DATABASES\*.*" - only single spaces in between
*-- ZIPparams: Some compression parameters [Optional]
* e(x) x = 'X' maximum compression
* x = '0' no compression (digital 0 not O)
* x = 'S' minimal compression
* x = 'N' normal compression (default)
* P include directory entries
* Spassword must be last part
*
* Return Values: the number of files archived or -1 if archive name not specified.
********************************************************************************************
FUNCTION aZip
PARAMETERS lInitialize, sArchive, sInclFiles, ZIPparams
PRIVATE Params, sTemp
Params = PARAMETERS()
* declare needed DLL functions & pass current window
IF Params = 0 OR lInitialize
PRIVATE HWND
DECLARE INTEGER GetActiveWindow IN win32api
HWND = GetActiveWindow()
DECLARE addZIP_Initialise IN AZIP32
DECLARE SHORT addZIP_SetParentWindowHandle IN AZIP32 SHORT @ HWindow
DECLARE SHORT addZIP_ArchiveName IN AZIP32 STRING @ sArchName
DECLARE SHORT addZIP_Include IN AZIP32 STRING @ sFileName
DECLARE SHORT addZIP_Recurse IN AZIP32 SHORT @ nRecurse
DECLARE SHORT addZIP_SetCompressionLevel IN AZIP32 SHORT @ nComprLvl
DECLARE SHORT addZIP_IncludeDirectoryEntries IN AZIP32 SHORT @ nInclDir
DECLARE SHORT addZIP_IncludeEmptyDirectoryEntries IN AZIP32 SHORT @ nInclEDir
DECLARE SHORT addZIP_Update IN AZIP32 SHORT @ nUpdate
DECLARE SHORT addZIP_Update IN AZIP32 SHORT @ nUpdate
DECLARE SHORT addZIP IN AZIP32
DECLARE SHORT addZIP_Register IN AZIP32 String @ RegName, Integer @ RegNum
DECLARE SHORT addZIP_Encrypt IN AZIP32 STRING @ sPassw
addZIP_Initialise()
addZIP_SetParentWindowHandle(HWND)
* addZIP_Register("RegistrationName", RegistrationNumber)
* Do above line if you have registered the software - it permits passwords
IF Params < 2
RETURN 0
ENDIF
ENDIF
IF Params < 3
?? CHR(7)
MESSAGEBOX('Missing parameters!',0, 'AZip Notice!')
RETURN 0
ENDIF
IF Params > 3 && ZIPparams exist
ZIPparams = ALLT(ZIPparams)
PRIVATE LastPos, PASSWORD, nCurPos
LastPos = LEN(ZIPparams) + 1
* check for password
nCurPos = ATC('S', ZIPparams)
IF nCurPos > 0
cPassWord = SUBSTR(ZIPparams, nCurPos+1)
addZIP_Encrypt(cPassWord)
ZIPparams = LEFT(ZIPparams, nCurPos -1) && now remove password part - it may have other code
ENDIF
* check for storing subdirectory information
nCurPos = ATC('P', ZIPparams)
IF nCurPos > 0
addZIP_Recurse(1)
addZIP_IncludeDirectoryEntries(1)
* addZIP_IncludeEmptyDirectoryEntries(1)
ENDIF
* check for compresion level
nCurPos = ATC('E', ZIPparams)
IF nCurPos > 0
PRIVATE cCompLevel, nCompLevel
cCompLevel = SUBSTR(ZIPparams, nCurPos + 1, 1)
DO CASE
CASE cCompLevel = 'X' && max compression
nCompLevel = 3
CASE cCompLevel = 'S' && min compression
nCompLevel = 1
CASE cCompLevel = '0' && no compression
nCompLevel = 0
OTHERWISE && normal/default compression
nCompLevel = 2
ENDCASE
addZIP_SetCompressionLevel(nCompLevel)
ENDIF
ELSE
addZIP_SetCompressionLevel(2)
ENDIF
addZIP_ArchiveName(sArchive) && specify archive filepath
sInclFiles = ALLT(STRTRAN(sInclFiles, ' ', '|')) && file(s) to zip
addZIP_Include(sInclFiles) && (sInclFiles)
Return addZIP() && do it & return # of files compressed
***************************************************************************************
Function aUnzip
* Azip procedure to unzip files for Visual FoxPro using the
* AddZip AUNZIP.DLL's from shareware
* [URL unfurl="true"]http://ourworld.compuserve.com/homepages/Stephen_Darlington/addzip.htm[/URL]
*
* Requirements: AUNZIP32.DLL in your Windows\system directory or current directory
*
* USAGE: AUNZIP(lInitialize, sArchive sDir[, sExtractFiles[, UnZIPparams]])
*
* PARAMETERS:
*-- lInitialize: .T. first time & Done only once beforeor when starting file zip - .F. afterward
*- Calling azip() with no params also initializes
*-- sArchive: Archive FileName with extension - Example "C:\THISFILE.ZIP"
*-- sDir: destination directory string
*-- Example1 "D:\TEMP"
*-- sExtractFiles(optional): string repr. file(s) or types to extract
*-- Default is "*.*"
*-- Example1 "C:\CUSTOMER.DBF"
*-- Example2 "C:\CUSTOMER.DBF D:\*.TXT D:\DATABASES\*.*" - only single spaces in between
*-- UnZIPparams: Some compression parameters [Optional]
* F freshen files - over older date/time or not existing
* D include directory information
* Overwrite: !!!!
* !!!! This does not seem to work except OverwriteNone - as of Aug. 1998 version.
* OA: overwrite all (default)
* O0: do not overwrite (letter O, digit 0)
* OU: ask user
* Spassword (Must be last part - works only with registered version)
*
* Return Values: the number of files archived or -1 if archive name not specified.
PARAMETERS Initialize, sArchive, sDir, sExtractFiles, UnZIPparams
PRIVATE Params, sTemp
Params = PARAMETERS()
* declare needed DLL functions & pass current window
IF Params = 0 OR Initialize
PRIVATE HWND
DECLARE INTEGER GetActiveWindow IN win32api
HWND = GetActiveWindow()
DECLARE addUNZIP_Initialise IN AUNZIP32
DECLARE SHORT addUNZIP_SetParentWindowHandle IN AUNZIP32 SHORT @ HWindow
DECLARE SHORT addUNZIP_ArchiveName IN AUNZIP32 STRING @ sArchName
DECLARE SHORT addUNZIP_RestoreStructure IN AUNZIP32 SHORT @ nResStr
DECLARE SHORT addUNZIP_Freshen IN AUNZIP32 SHORT @ nFreshn
DECLARE SHORT addUNZIP_Include IN AUNZIP32 STRING @ sFileName && default is *.*
DECLARE SHORT addUNZIP_ExtractTo IN AUNZIP32 STRING @ sExtrTo
DECLARE SHORT addUNZIP_Register IN AUNZIP32 STRING @ RegName, INTEGER @ RegNum
DECLARE SHORT addUNZIP_Decrypt IN AUNZIP32 STRING @ sPassw
DECLARE SHORT addUNZIP_Overwrite IN AUNZIP32 SHORT @ nOvLevel
DECLARE SHORT addUNZIP IN AUNZIP32
addUNZIP_Initialise()
addUNZIP_SetParentWindowHandle(HWND)
* addUNZIP_Register("RegistrationName", RegistrationNumber)
IF Params < 2
RETURN 0
ENDIF
ENDIF
IF Params < 3
?? CHR(7)
MESSAGEBOX('Missing parameters!',0, 'AUNZip Notice!')
RETURN 0
ENDIF
IF Params > 3 && UnZIPparams exist
UnZIPparams = ALLT(UnZIPparams)
PRIVATE LastPos, PASSWORD, nCurPos
LastPos = LEN(UnZIPparams) + 1
* check for password
nCurPos = ATC('S', UnZIPparams)
IF nCurPos > 0
cPassWord = SUBSTR(UnZIPparams, nCurPos+1)
addUNZIP_Decrypt(cPassWord)
UnZIPparams = LEFT(UnZIPparams, nCurPos -1) && now remove password part - it may have other code
ENDIF
* check for restoring subdirectory information
nCurPos = ATC('D', UnZIPparams)
IF nCurPos > 0
addUNZIP_RestoreStructure(1)
ENDIF
* check for freshen
nCurPos = ATC('F', UnZIPparams)
IF nCurPos > 0
addUNZIP_RestoreStructure(1)
ENDIF
* check for Overwrite - this does not seem to work except, OverwriteNone
DO CASE
CASE 'OA' $ UnZIPparams && Overwrite all
addUNZIP_Overwrite(0x0b)
CASE 'O0' $ UnZIPparams && overwrite none
addUNZIP_Overwrite(0x0c)
CASE 'OU' $ UnZIPparams && overwrite ask user
addUNZIP_Overwrite(0x0a)
ENDCASE
IF nCurPos > 0
addUNZIP_RestoreStructure(1)
ENDIF
ELSE
addUNZIP_Overwrite(0x000a) && this does not seem to work except OverwriteNone
ENDIF
addUNZIP_ArchiveName(sArchive)
addUNZIP_ExtractTo(ALLT(sDir))
sExtractFiles = IIF(Params<4, "*.*", ALLT(STRTRAN(sExtractFiles, ' ', '|'))) && file(s) to extract
addUNZIP_Include(sExtractFiles) && files to extract - *.txt, *.*, etc.
RETURN addUNZIP()
-Bart
Fo