Page 1 of 1
HB_UnZipFile() no me descomprime
Posted: Sat Jan 17, 2015 11:59 am
by colthop
Hola Amigos:
Tengo una opción que viene heredada de xHarbour en la que funcionaba bien pero ahora en Harbour me está dando el siguiente problema:
Cuando descomprimo un archivo desde el programa con HB_UnZipFile() me descomprime todos los archivos que ya tengan la carpeta destino creada pero los que no la tiene no lo hace.
El fuente es muy sencillo y es:
Code: Select all
cFilZip = hb_CurDrive() + ":\" + CurDir() + "\cyewin\Actu\" + trim(nombre)
aExtract := hb_GetFilesInZip(cFilZip)
Porce = 0
nLen = len(hb_GetFilesInZip(cFilZip))
aDire = hb_CurDrive()+":\"+CurDir()+"\"
DEFINE DIALOG odlgw1 OF oVentPrinc FONT oFont FROM 0,0 TO 10,80 COLOR escri1, fondo1 TITLE "Copiando Archivos" STYLE nOr(WS_POPUP, WS_DLGFRAME)
@ 1, 1 SAY odlgz02 VAR wtex051 + substr(nombre,1,10) OF odlgw1 COLOR escri1, fondo1 FONT oFont SIZE 300,20 CENTER
@ 3, 1 METER odlgz01 VAR porce TOTAL 100 OF odlgw1 SIZE 300,20 COLOR fondo1, escri3 BARCOLOR escri3, fondo1
ACTIVATE DIALOG oDlgw1 CENTERED on Paint(If(HB_UnZipFile(cFilZip,{|cFilZip,nPos|Porce:=nPos/nLen*100,oDlgz01:Set(Porce)},.T.,,aDire,aExtract,nil), va003 = "1", va003 = "2" ),oDlgw1:End())
Si alguien puede ayudarme, muchas gracias.
Un saludo
Carlos
Re: HB_UnZipFile() no me descomprime
Posted: Sat Jan 17, 2015 12:32 pm
by colthop
Hola de nuevo.
He estado mirando y encontrado esta otra manera pero esta no me avanza la descompresión.
Code: Select all
PROCEDURE cyewin12()
LOCAL oDlg,nLen,aExtract,oText, oMeter,Porce:=0
va003 = "1"
cFile = hb_CurDrive() + ":\" + CurDir() + "\cyewin\Actu\" + nombre
aExtract := hb_GetFilesInZip(cFile)
nLen = len(hb_GetFilesInZip(cFile))
aDire = hb_CurDrive()+":\"+CurDir()+"\"
DEFINE DIALOG odlgw1 OF oVentPrinc FONT oFont FROM 0,0 TO 10,80 COLOR escri1, fondo1 TITLE "Copiando Archivos" STYLE nOr(WS_POPUP, WS_DLGFRAME)
@ 1, 1 SAY oText VAR wtex051 + substr(nombre,1,10) OF odlgw1 COLOR escri1, fondo1 FONT oFont SIZE 300,20 CENTER
@ 3, 1 METER oMeter VAR porce TOTAL 100 OF odlgw1 SIZE 300,20 COLOR fondo1, escri3 BARCOLOR escri3, fondo1
oDlg:bStart := { || lVal:=Hb_UnZipFile( cFile,{|cFile,nPos|oMeter:SetText(wtex051 + substr(nombre,1,10)),Porce:=nPos/nLen*100,odlgz01:Set(Porce)},.T.,,aDire,aExtract,NIL),if(lVal, va003 = "1", va003 = "2"),oDlg:End()}
ACTIVATE DIALOG oDlgw1 CENTERED
Por si alguien me puede decir el porque y a ver si de esta manera si se puede hacer la descompresión correctamente.
Un saludo
Carlos
Re: HB_UnZipFile() no me descomprime
Posted: Mon Apr 27, 2015 2:43 pm
by nageswaragunupudi
The function HB_UnzipFile(...) in ziparc.prg of Harbour has a few bugs.
I prepared a modified function HB_UnzipFileRevd(...) in this module and link with my Harbour applications. I use HB_UnzipFileRevd(...) instead of HB_UnzipFile(...) when using Harbour.
hbunzip.prg:
Code: Select all
// hbunzip.prg
#include "fileio.ch"
#define UNZ_OK 0 // from hbmzip.ch
#define REVD
#ifdef __XHARBOUR__
#error This module is for Harbour Only
#else
//----------------------------------------------------------------------------//
#ifdef REVD
FUNCTION hb_UnzipFileRevd( cFileName, bUpdate, lWithPath, cPassword, cPath, acFiles, bProgress )
#else
FUNCTION hb_UnzipFile( cFileName, bUpdate, lWithPath, cPassword, cPath, acFiles, bProgress ) // ziparc.prg
#endif
LOCAL lRetVal := .T.
LOCAL hUnzip
LOCAL nErr
LOCAL nPos
LOCAL cZipName
LOCAL lExtract
LOCAL hHandle
LOCAL nSize
LOCAL nRead
LOCAL nLen
LOCAL dDate
LOCAL cTime
LOCAL cBuffer := Space( 32768 )
#ifdef REVD
IF lWithPath == nil
lWithPath := .t.
ENDIF
#else
IF hb_defaultValue( lWithPath, .F. ) .AND. ! hb_DirExists( cPath ) .AND. hb_DirCreate( cPath ) != 0
lRetVal := .F.
ENDIF
#endif
IF Empty( cPassword )
cPassword := NIL
ENDIF
IF Set( _SET_DEFEXTENSIONS )
cFileName := hb_FNameExtSetDef( cFileName, ".zip" )
ENDIF
IF Empty( hUnzip := hb_unzipOpen( cFileName ) )
lRetVal := .F.
ELSE
IF HB_ISNUMERIC( acFiles ) .OR. ;
HB_ISSTRING( acFiles )
acFiles := { acFiles }
ENDIF
IF Empty( cPath )
cPath := hb_FNameDir( cFileName )
ENDIF
cPath := hb_DirSepAdd( cPath )
nPos := 0
nErr := hb_unzipFileFirst( hUnzip )
DO WHILE nErr == 0
nPos++
IF hb_unzipFileInfo( hUnzip, @cZipName, @dDate, @cTime,,,, @nSize ) == 0
/* NOTE: As opposed to original hbziparch we don't do a second match without path. */
#ifdef REVD
lExtract := Empty( acFiles ) .OR. ;
AScan( acFiles, nPos ) > 0 .OR. ;
AScan( acFiles, {| cMask | hb_FileMatch( StrTran( cZipName, '/', '\' ), StrTran( cMask, '/', '\' ) ) } ) > 0
IF lExtract .AND. ( hHandle := FCreateEx( cPath, cZipName, lWithPath ) ) != F_ERROR
#else
lExtract := Empty( acFiles ) .OR. ;
AScan( acFiles, nPos ) > 0 .OR. ;
AScan( acFiles, {| cMask | hb_FileMatch( cZipName, cMask ) } ) > 0
IF lExtract .AND. ( hHandle := FCreate( cPath + cZipName ) ) != F_ERROR
#endif
IF hb_unzipFileOpen( hUnzip, cPassword ) != UNZ_OK
lRetVal := .F.
EXIT
ENDIF
nRead := 0
DO WHILE ( nLen := hb_unzipFileRead( hUnzip, @cBuffer, hb_BLen( cBuffer ) ) ) > 0
IF HB_ISEVALITEM( bProgress )
nRead += nLen
Eval( bProgress, nRead, nSize )
ENDIF
FWrite( hHandle, cBuffer, nLen )
ENDDO
hb_unzipFileClose( hUnzip )
FClose( hHandle )
hb_FSetDateTime( cPath + cZipName, dDate, cTime )
IF HB_ISEVALITEM( bUpdate )
Eval( bUpdate, cZipName, nPos )
ENDIF
ENDIF
ENDIF
nErr := hb_unzipFileNext( hUnzip )
ENDDO
hb_unzipClose( hUnzip )
ENDIF
RETURN lRetVal
//----------------------------------------------------------------------------//
#ifdef REVD
static function FCreateEx( cPath, cZipName, lWithPath )
local nRet := -1
local cFile
cZipName := StrTran( cZipName, '/', '\' )
cFile := cPath + If( lWithPath, cZipName, cFileNoPath( cZipName ) )
cPath := cFilePath( cFile )
if ! hb_DirExists( cPath )
hb_DirBuild( cPath )
endif
return FCreate( cFile )
//----------------------------------------------------------------------------//
#endif // ifdef REVD
#endif // ifndef __XHARBOUR__
Re: HB_UnZipFile() no me descomprime
Posted: Sat Aug 04, 2018 3:51 pm
by MGA
Mr Rao
estou tentando utilizar
hb_UnzipFileRevd
e não estou conseguindo, existe um exemplo de uso para DESCOMPACTAR arquivos RAR?
Re: HB_UnZipFile() no me descomprime
Posted: Sat Aug 04, 2018 3:57 pm
by Enrico Maria Giordano
Unzip functions are for ZIP archives, not for RAR.
EMG
Re: HB_UnZipFile() no me descomprime
Posted: Mon Aug 06, 2018 12:38 pm
by karinha