Página 1 de 1

Fix ZipFile

Publicado: Mar Nov 05, 2013 1:59 pm
por emeasoft
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

Fix ZipFile

Publicado: Mar Nov 05, 2013 2:39 pm
por ignacio
Hello,
Thanks your code, but before including it I need to understand the problem and your solution. A small sample would be great. TIA.
Regards

Fix ZipFile

Publicado: Mié Nov 06, 2013 11:43 am
por emeasoft
Hello Ignacio,
The problem is that it is compacting the content of a folder, when there is only one path to compact and it is not making its folder tree...
I made two examples to show that.
TIA,
Juliano

Attached files Test-with-fix.zip (6.8 KB)Â Test-without-fix.zip (2.7 KB)Â

Fix ZipFile

Publicado: Mié Nov 06, 2013 12:28 pm
por ignacio
emeasoft escribió el mié, 06 noviembre 2013 11:43Hello Ignacio,
The problem is that it is compacting the content of a folder, when there is only one path to compact and it is not making its folder tree...
I made two examples to show that.
TIA,
Juliano
Thanks for the sample. Ok, I understood the problem. Sorry for being so cautious and thank you again for your feedback.
Regards,

Fix ZipFile

Publicado: Mié Nov 06, 2013 3:17 pm
por emeasoft
Many thanks for your help Ignacio!
Regards,
Juliano