HB_UnZipFile() no me descomprime

HB_UnZipFile() no me descomprime

Postby colthop » Sat Jan 17, 2015 11:59 am

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  Expand view

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
Colt Hop ED, S.L.
Carlos Blas Fernández Domínguez
Tlfo: 645847093
E-Mail: carlos@colthop.es

Nunca se termina de aprender, por eso necesito siempre ayuda.
colthop
 
Posts: 505
Joined: Sat Apr 22, 2006 9:09 am
Location: Madrid - España

Re: HB_UnZipFile() no me descomprime

Postby colthop » Sat Jan 17, 2015 12:32 pm

Hola de nuevo.

He estado mirando y encontrado esta otra manera pero esta no me avanza la descompresión.

Code: Select all  Expand view

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
Colt Hop ED, S.L.
Carlos Blas Fernández Domínguez
Tlfo: 645847093
E-Mail: carlos@colthop.es

Nunca se termina de aprender, por eso necesito siempre ayuda.
colthop
 
Posts: 505
Joined: Sat Apr 22, 2006 9:09 am
Location: Madrid - España

Re: HB_UnZipFile() no me descomprime

Postby nageswaragunupudi » Mon Apr 27, 2015 2:43 pm

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  Expand view
// 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__
Regards

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

Re: HB_UnZipFile() no me descomprime

Postby MGA » Sat Aug 04, 2018 3:51 pm

Mr Rao

estou tentando utilizar

hb_UnzipFileRevd

e não estou conseguindo, existe um exemplo de uso para DESCOMPACTAR arquivos RAR?
ubiratanmga@gmail.com

FWH18.02
FWPPC
Harbour/xHarbour
xMate
Pelles´C
TDolphin
MGA
 
Posts: 1234
Joined: Mon Feb 25, 2008 2:54 pm
Location: Brasil/PR/Maringá

Re: HB_UnZipFile() no me descomprime

Postby Enrico Maria Giordano » Sat Aug 04, 2018 3:57 pm

Unzip functions are for ZIP archives, not for RAR.

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

Re: HB_UnZipFile() no me descomprime

Postby karinha » Mon Aug 06, 2018 12:38 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7339
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 63 guests