HB_UnzipFile()

HB_UnzipFile()

Postby Baxajaun » Sat Feb 11, 2017 4:33 pm

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
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: HB_UnzipFile()

Postby Enrico Maria Giordano » Sat Feb 11, 2017 7:02 pm

I never found problems with HB_UnzipFile() using files and directories. Can I see a little sample showing the problem?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: HB_UnzipFile()

Postby Baxajaun » Sat Feb 11, 2017 7:24 pm

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,
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: HB_UnzipFile()

Postby Enrico Maria Giordano » Sat Feb 11, 2017 9:02 pm

Sorry, I need of a real sample that can be compiled and run here. I cannot reproduce the problem.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: HB_UnzipFile()

Postby Baxajaun » Sat Feb 11, 2017 9:40 pm

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
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: HB_UnzipFile()

Postby Enrico Maria Giordano » Sat Feb 11, 2017 10:03 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: HB_UnzipFile()

Postby Baxajaun » Sat Feb 11, 2017 10:21 pm

Enrico,

i use Harbour. Your sample not work in Harbour. Perhaps, the problem is in Harbour's libs.

Regards
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: HB_UnzipFile()

Postby Enrico Maria Giordano » Sat Feb 11, 2017 10:27 pm

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
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: HB_UnzipFile()

Postby Baxajaun » Sat Feb 11, 2017 10:43 pm

Enrico,

is not works.

Regards
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: HB_UnzipFile()

Postby Enrico Maria Giordano » Sat Feb 11, 2017 10:48 pm

Ok, so it's Harbour. Anybody can report this to the Harbour developers?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: HB_UnzipFile()

Postby nageswaragunupudi » Sun Feb 12, 2017 3:04 am

Please see
viewtopic.php?f=6&t=30003&p=175748&hilit=hb_UnzipFile#p175748

I published a revised function fixing the problems in Harbour
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10641
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: HB_UnzipFile()

Postby Baxajaun » Sun Feb 12, 2017 6:30 am

Thanks a lot Mr. Rao !
User avatar
Baxajaun
 
Posts: 968
Joined: Wed Oct 19, 2005 2:17 pm
Location: Gatika. Bizkaia

Re: HB_UnzipFile()

Postby Enrico Maria Giordano » Sun Feb 12, 2017 9:43 am

I think it would be better to fix the problem in Harbour.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8715
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 23 guests

cron