Fix ZipFile
Publicado: Mar Nov 05, 2013 1:59 pm
Hello Ignacio,
If the path of the files to zip was only one, it was compacting only the contents from that dir... so I changed this on the class to solve the problem.
Here is the fix for the TZipFile:
METHOD CommonMaskPath() CLASS XZipFile
LOCAL cPath, cMask
LOCAL nLen, nPos, nFor
LOCAL l01:=.F.
IF ValType( ::aFileMask ) == "C"
::aFileMask := { ::aFileMask }
ENDIF
cPath := ::aFileMask[ 1 ]
FOR nFor := 2 TO Len( ::aFileMask )
cMask := ::aFileMask[ nFor ]
nPos := 1
nLen := Min( Len( cPath ), Len( cMask ) )
DO WHILE nPos <= nLen
IF Upper( Left( cPath, nPos ) ) == Upper( Left( cMask, nPos ) )
nPos++
ELSE
IF ""$SubStr(cMask,nPos)
l01:=.T.
ENDIF
EXIT
ENDIF
ENDDO
cPath := Left( cPath, nPos - 1 )
IF Empty( cPath )
EXIT
ENDIF
NEXT
IF ( nPos := RAt( "", cPath ) ) > 0
cPath := Left( cPath, nPos )
ENDIF
IF !l01
IF ( nPos := HB_At( "", cPath ) ) > 0
cPath := Left( cPath, nPos )
ENDIF
ENDIF
RETURN cPath
Regards,
Juliano
If the path of the files to zip was only one, it was compacting only the contents from that dir... so I changed this on the class to solve the problem.
Here is the fix for the TZipFile:
METHOD CommonMaskPath() CLASS XZipFile
LOCAL cPath, cMask
LOCAL nLen, nPos, nFor
LOCAL l01:=.F.
IF ValType( ::aFileMask ) == "C"
::aFileMask := { ::aFileMask }
ENDIF
cPath := ::aFileMask[ 1 ]
FOR nFor := 2 TO Len( ::aFileMask )
cMask := ::aFileMask[ nFor ]
nPos := 1
nLen := Min( Len( cPath ), Len( cMask ) )
DO WHILE nPos <= nLen
IF Upper( Left( cPath, nPos ) ) == Upper( Left( cMask, nPos ) )
nPos++
ELSE
IF ""$SubStr(cMask,nPos)
l01:=.T.
ENDIF
EXIT
ENDIF
ENDDO
cPath := Left( cPath, nPos - 1 )
IF Empty( cPath )
EXIT
ENDIF
NEXT
IF ( nPos := RAt( "", cPath ) ) > 0
cPath := Left( cPath, nPos )
ENDIF
IF !l01
IF ( nPos := HB_At( "", cPath ) ) > 0
cPath := Left( cPath, nPos )
ENDIF
ENDIF
RETURN cPath
Regards,
Juliano