HB_UnzipFile () does not work correctly if your zip file contains files and directories.
Thanks to Juan Kazmirchuk, this function fix the problem.
- Code: Select all Expand view
//-----------------------------------------------------------------------------
// Juan Kazmirchuk
//-----------------------------------------------------------------------------
FUNCTION my_UnZipFile( cFile, bBlock, lWithPath, cPassword, cPath )
LOCAL lZip
LOCAL nI
LOCAL aFiles := { }
LOCAL aFolders := { }
LOCAL nfiles := 0
// Get files in ZIP
aFiles := hb_GetFilesInZip( cFile )
nFiles := len(aFiles)
// Get folders in ZIP and create at cPath
FOR nI := 1 TO nFiles
IF ! HB_DirExists( HB_DirSepToOS( HB_FNameDir( aFiles[nI] ) ) )
HB_DirCreate( HB_DirSepAdd( cPath ) + HB_DirSepToOS( HB_FNameDir( aFiles[nI] ) ) )
ENDIF
NEXT
// Then UnZIP files in Path folder
lZip := HB_UnZipFile( cFile, ;
NIL, ;
.T., ;
NIL, ;
cPath, ;
aFiles )
RETURN lZip
Regards