Page 1 of 1
HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 4:33 pm
by Baxajaun
Hi,
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
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 7:02 pm
by Enrico Maria Giordano
I never found problems with HB_UnzipFile() using files and directories. Can I see a little sample showing the problem?
EMG
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 7:24 pm
by Baxajaun
Hi Enrico,
with this code
- Code: Select all Expand view
lZip := HB_UNZIPFILE( cFolder + "\" + cFile,,.T.,,cFolder,aFileZip,NIL )
lzip is TRUE, but files are not uncompressed.
With
- Code: Select all Expand view
lZip := my_UnZipFile( cFolder + "\" + cFile,,.t.,,cFolder,aFileZip )
the files and dirextories are uncompressed.
In my case HB_UnzipFile() works perfectly with zip files without directories.
Best regards,
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 9:02 pm
by Enrico Maria Giordano
Sorry, I need of a real sample that can be compiled and run here. I cannot reproduce the problem.
EMG
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 9:40 pm
by Baxajaun
Enrico,
please compress Fivewin Samples directory.
- Code: Select all Expand view
#include "Fivewin.ch"
Function Main()
Local nFilesInZip:= 0
Local aFilesInZip := {}
Local cFile := "samples.zip"
Local lZip
Local cPath := StrCapFirst( cFilePath( GetModuleFileName( GetInstance() ) ) )
nFilesInZIP := LEN(hb_GetFilesInZip(cFile))
aFilesInZip := hb_GetFilesInZip(cFile,.t.)
lZip := HB_UNZIPFILE( cFile,,.T.,,cpath,aFilesInZip,NIL )
if lzip
MsgInfo("Fichero descomprimido")
endif
/*
IF my_UnZipFile( cFile,,.t.,,".\",aFilesInZip )
MsgInfo("Fichero descomprimido")
ENDIF
*/
Return NIL
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
Best regards
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 10:03 pm
by Enrico Maria Giordano
This sample works fine here (latest xHarbour and FWH):
- Code: Select all Expand view
#include "Fivewin.ch"
FUNCTION MAIN()
LOCAL cZip := "samples.zip"
? HB_UNZIPFILE( cZip, , .T., , CURDRIVE() + ":\" + CURDIR(), HB_GETFILESINZIP( cZip ) )
RETURN NIL
EMG
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 10:21 pm
by Baxajaun
Enrico,
i use Harbour. Your sample not work in Harbour. Perhaps, the problem is in Harbour's libs.
Regards
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 10:27 pm
by Enrico Maria Giordano
Baxajaun wrote:Enrico,
i use Harbour. Your sample not work in Harbour. Perhaps, the problem is in Harbour's libs.
Regards
Please try my sample using pure Harbour (no FWH) and tell me if it works.
EMG
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 10:43 pm
by Baxajaun
Enrico,
is not works.
Regards
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sat Feb 11, 2017 10:48 pm
by Enrico Maria Giordano
Ok, so it's Harbour. Anybody can report this to the Harbour developers?
EMG
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sun Feb 12, 2017 3:04 am
by nageswaragunupudi
Please see
viewtopic.php?f=6&t=30003&p=175748&hilit=hb_UnzipFile#p175748I published a revised function fixing the problems in Harbour
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sun Feb 12, 2017 6:30 am
by Baxajaun
Thanks a lot Mr. Rao !
Re: HB_UnzipFile()
![Post Post](./styles/prosilver/imageset/icon_post_target.gif)
Posted:
Sun Feb 12, 2017 9:43 am
by Enrico Maria Giordano
I think it would be better to fix the problem in Harbour.
EMG