FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour using hb_unzipfile
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
using hb_unzipfile
Posted: Sat Mar 14, 2026 08:49 AM

how can I unpack file "paczka1.zip" to folder ".\kat1" using hb_unzipfile

best regards kajot

best regards

kajot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: using hb_unzipfile
Posted: Sat Mar 14, 2026 08:59 AM

Dear Kajot,

hb_UnzipFile( "paczka1.zip",, .T.,, ".\kat1" )

FUNCTION hb_UnzipFile( cFileName, bUpdate, lWithPath, cPassword, cPath, acFiles, bProgress )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
Re: using hb_unzipfile
Posted: Sat Mar 14, 2026 09:24 AM

does hb_UnzipFile works in xHARBOUR

best regards

kajot
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
Re: using hb_unzipfile
Posted: Sat Mar 14, 2026 11:03 AM

function hb_zipfile work OK

but hb_unzipfile don't unpack files

KAJOT

best regards

kajot
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: using hb_unzipfile
Posted: Mon Mar 16, 2026 12:52 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
Re: using hb_unzipfile
Posted: Thu Mar 19, 2026 09:40 PM

I am using xHarbour

Result := hb_UnzipFile( cZipFile,, .T.,, pcDestPath, paFile )

it doesn't work

best regards

kajot
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: using hb_unzipfile
Posted: Fri Mar 20, 2026 06:27 AM

Dear Kajot,

The variable pUnzip is only assigned if parameter 6 is an array or string. But pUnzip is not initialized — if
parameter 6 is missing/NIL, pUnzip has an undefined value, and the code at line 754 (if( pUnzip )) could behave
unpredictably.

More importantly, the 6th parameter (paFile) is mandatory. From the docs:

â–Ž If <cFile> or <aFiles> are not provided, no files will be extracted!

Your call is:

hb_UnzipFile( cZipFile,, .T.,, pcDestPath, paFile )

This looks syntactically correct. The problem could be one of these:

  1. paFile is empty or NIL — make sure it contains the actual filenames inside the zip. Use hb_GetFilesInZip() first to
    get them:

paFile := hb_GetFilesInZip( cZipFile )
Result := hb_UnzipFile( cZipFile,, .T.,, pcDestPath, paFile )

  1. pcDestPath must end with a backslash — the C code uses it directly as a path:

    pcDestPath := "C:\MyFolder\" // must end with backslash

  2. The path must already exist — lWithPath (.T.) creates subdirectories within the zip structure, but the destination
    folder itself must exist.

  3. File names in paFile must match exactly what's stored in the zip (including paths inside the zip). Check with:

    aFiles := hb_GetFilesInZip( cZipFile )
    AEval( aFiles, {|c| QOut(c) } )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 410
Joined: Sun Jan 31, 2010 03:30 PM
Re: using hb_unzipfile
Posted: Fri Mar 20, 2026 12:14 PM

Antonio

Solucionado... Gracias

              vFilXml := hb_GetFilesInZip( cFilZip )

          IF LEN(vFilXml) == 0
             AADD(aErrZip,{cFilZip,"","Archivo .zip no contiene archivos "})
          ELSE

             //  RUN ("7z x " +cFilZip+ " -o"+  xPatLoc +" -y *.xml -bso0 -bsp0 -bse0" )

             hb_UnzipFile( cFilZip,, .T.,, xPatLoc+"\", vFilXml )
             cFilXml := ""
             for K := 1 to len(vFilXml)
                 IF Lower(Right(vFilXml[K], 4)) == ".xml"
                    cFilXml :=  ALLTRIM(vFilXml[K])  // analiza el primer xml encontrado... no deberian existir mas de uno!!
                    exit
                 ENDIF
             next

             cFilXmlIni := cFilXml
             cFilXml := xPatLoc+"\"+cFilXml

             IF !fileExiste(cFilXml)
                AADD(aErrZip,{cFilZip,cFilXml,"Archivo XML no existe"})
             ELSE
             //
             ENDIF
Posts: 357
Joined: Thu Nov 02, 2006 06:53 PM
Re: using hb_unzipfile
Posted: Fri Mar 20, 2026 06:22 PM

my sample

sc0 :=curdrive()+':'+'\'+curdir()+'\'
 zb:='PaczkaFaktur.zip'

 if file(zb)
      aFiles := hb_GetFilesInZip( zb , .t.)         
      AEval( aFiles, {|c| QOut(c) } )

      IF LEN(aFiles) > 0
   

         lOK:=hb_UnzipFile( zb,,.T.,, sc0, aFiles)

         alert(iif(lOK, "OK", "NO") )

      else
         alert('Zip nie zawiera plikow.')

      endif
  else
      alert('Brak zbioru '+zb)
  endif
best regards

kajot
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: using hb_unzipfile
Posted: Sun Mar 22, 2026 06:33 PM
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: using hb_unzipfile
Posted: Mon Mar 23, 2026 04:43 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion