Funciones de archivos ZIP no andan

Funciones de archivos ZIP no andan

Postby cmsoft » Tue Oct 24, 2006 11:59 am

Estimados:
Quiero utilizar las funciones para menejo de archivos zip, y no me funcionan.
Cuando compilo el ejemplo que TESTZIP, me da los siguientes errores:
Error: Unresolved external ´_HB_FUN_ZIPFILE´
Error: Unresolved external ´_HB_FUN_ZIPTYPE´
Error: Unresolved external ´_HB_FUN_ZIPBLOCK´
Error: Unresolved external ´_HB_FUN_ZIPMSG´
Alguien me puede dar una mano
Atte.
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Postby Antonio Linares » Tue Oct 24, 2006 12:04 pm

Esas funciones de FW no están disponibles en 32 bits.

Tienes que usar la librería hbzip.lib de xharbour. Tienes ejemplos de uso en xharbour\tests
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby cmsoft » Tue Oct 24, 2006 12:09 pm

Gracias Antonio por tu pronta respuesta.
Disculpa mi ignorancia, estas funciones no andan con HARBOUR + FWH?
Si es así, que puedo utilizar para manejar archivos ZIP con HARBOUR + FWH?
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Postby Manuel Aranda » Tue Oct 24, 2006 3:32 pm

Hola cmSoft, tienes que utilizar xHarbour, en Harbour no está disponible hbzip.lib. Mírate esto http://fivetechsoft.com/forums/viewtopic.php?t=4594

Un saludo,
Manuel
User avatar
Manuel Aranda
 
Posts: 602
Joined: Wed Oct 19, 2005 8:20 pm
Location: España

Postby cmsoft » Tue Oct 24, 2006 3:56 pm

Gracias Manuel: El link no funciona (por lo menos para mi pais), puedes pasarmelo por privado?
Desde ya muchas gracias...
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Postby Manuel Aranda » Tue Oct 24, 2006 4:04 pm

El link se corresponde con el título HBZipFile, hb_UnZipFile y Meter del dia 20-10-2006 en este mismo foro.

Saludos,
Manuel
User avatar
Manuel Aranda
 
Posts: 602
Joined: Wed Oct 19, 2005 8:20 pm
Location: España

Solución, creo

Postby Paco Garcia » Tue Oct 24, 2006 4:31 pm

Hola,

Buceando por esos mundos he encontrado dos DLLs que son freeware

Se trata de LiteZip y LiteUnzip

http://www.codeproject.com/useritems/LiteZip.asp

Descargaros los fuentes y obteneis las dlls. Tambien teneis que utilizar los fichero .h que se incluyen en la sección #pragma BEGINDUMP

El ejemplo que seguro no funciona del todo correctamente pero ayudará en el camino hacia el exito, es este:


Code: Select all  Expand view
#include "fivewin.ch"

function main()
local oWnd
local oMenu

MENU oMenu
  MENUITEM "Zip" ACTION Test()
ENDMENU



DEFINE WINDOW oWnd TITLE "Prueba de ventana" MENU oMenu





ACTIVATE WINDOW oWnd MAXIMIZED


return nil




function test()
local oDlg
local oLbx1
local oLbx2
local oMeter
local oAdd, oOut, oName, oComprimir, oIn, oNameIn, oExtract
local cFileOut := space( 300 )
local cFileIn  := space( 300 )

local aItems1 := {}
local aItems2 := {}
local cItem  := ""

local nPercent := 0





DEFINE DIALOG oDlg NAME "IDD_ABOUTBOX"


       REDEFINE GET oIn VAR cFileIn                    ID 101 OF oDlg
       REDEFINE BUTTON  oNameIn                        ID 102 OF oDlg ACTION SelName( oIn )
       REDEFINE LISTBOX oLbx1  VAR cItem ITEMS aItems1 ID 103 OF oDlg
       REDEFINE BUTTON  oExtract                       ID 104 OF oDlg ACTION Abrir( cFileIn, oLbx1, oMeter )

       REDEFINE GET oOut VAR cFileOut                  ID 105 OF oDlg
       REDEFINE BUTTON  oName                          ID 106 OF oDlg ACTION SelName( oOut )
       REDEFINE LISTBOX oLbx2  VAR cItem ITEMS aItems2 ID 107 OF oDlg
       REDEFINE BUTTON  oAdd                           ID 108 OF oDlg ACTION Add( oLbx2 )
       REDEFINE BUTTON  oComprimir                     ID 109 OF oDlg ACTION Comprimir( oLbx2, oOut, oMeter )
       REDEFINE METER oMeter VAR nPercent TOTAL 100    ID 110 OF oDlg


ACTIVATE DIALOG oDlg CENTERED



return nil


/////////////////////////////////////////////////////////////////////////////
  static function Abrir( cFileName,  oLbx, oMeter )
/////////////////////////////////////////////////////////////////////////////
local n
local hUnz
local aInfo
local nItems
local cFile
local cCurDir := curdrive() + ":\" + curdir() + "\"

cFileName := alltrim( cFileName )

if empty( cFileName )
   MsgStop( "Debe indicar un nombre de fichero" )
   return 0
endif

if !File( cFileName )
   MsgStop( "No se encuentra el fichero:" + CRLF + CRLF + cFileName )
   return 0
endif

hUnz := UnzipOpenFile( cFileName )

aInfo := UnzipGetItem( hUnz, -1 )
nItems := aInfo[2]
oMeter:SetTotal( nItems )

for n := 0 to nItems-1
     aInfo := UnzipGetItem( hUnz, n )
     if !empty( aInfo )
        cFile := aInfo[7]
        if lower( cCurdir ) $ lower( cFile )
           cFile := substr( cFile, len( cCurDir )+1 )
        endif
        cFile := alltrim( cFile )
        oLbx:Add( cFile )
     endif
     oMeter:Set( n )
next
UnzipClose()



return nil


/////////////////////////////////////////////////////////////////////////////
  static function Add( oLbx )
/////////////////////////////////////////////////////////////////////////////
local aFiles := cGetFileEx( "*.*", "Seleccione ficheros" )
local n

if empty( aFiles )
   return 0
endif

if valtype( aFiles ) == "C"
   aFiles := {aFiles}
endif

for n := 1 to len( aFiles )
    oLbx:Add( aFiles[n] )
next

return nil

/////////////////////////////////////////////////////////////////////////////
  static function SelName( oGet, lLoad )
/////////////////////////////////////////////////////////////////////////////

local cFileName
if lLoad == nil; lLoad := .f.; endif

cFileName := cGetFile( "*.zip",if( lLoad, "Seleccione fichero","Guardar como..."), 1, , lLoad )

if empty( cFileName )
   MsgInfo( "Proceso cancelado","Atención")
   return 0
endif

if lLoad .and. !( "." $ cFileName )
   cFileName += ".zip"
endif

oGet:cText := cFileName
oGet:Refresh()

if lLoad



endif



return 0

/////////////////////////////////////////////////////////////////////////////
  static function Comprimir( oLbx, oGet, oMeter )
/////////////////////////////////////////////////////////////////////////////

local cFileName
local n
local nLen := oLbx:Len()
local hZip
local cFile

if nLen <= 0
   MsgStop( "Debe seleccionar ficheros para comprimir","Atención")
   return 0
endif

cFileName := alltrim(oGet:cText)

if empty( cFileName )
   MsgStop( "Debe indicar el nombre de un fichero valido","Atención")
   return 0
endif

if !( "." $ cFileName )
   cFileName += ".zip"
endif


oMeter:SetTotal( nLen )

hZip := ZipCreateFile( cFileName )

for n := 1 to nLen
    cFile := oLbx:aItems[n]
    ZipAddFile( hZip, cFileName( cFile ), cFile )
    oMeter:Set(n)
next

ZipClose( hZip )

MsgInfo( "Proceso concluido" )


return nil





#pragma BEGINDUMP
#include "windows.h"
#include "hbapi.h"
#include <shlobj.h>
#include <stdlib.h>
#include "j:\litezip.h"
#include "j:\liteunzip.h"


static far char IniDir[] = ".\\";
static char szDirName[ MAX_PATH ];
static far char Title[] = "Select the file";

#define S_ARRAY        0x8000




HB_FUNC( ZIPCREATEFILE )
{
    HZIP hz;
    hb_retnl((long)ZipCreateFile(&hz, hb_parc( 2 ),0); // ,0 es la  pwd
    hb_stornl( (long)hz, 1 );

}

HB_FUNC( ZIPADDFILE )
{
   HZIP hz = (HZIP) hb_parnl( 1 );
   hb_retnl( ZipAddFile( hz, hb_parc( 2 ), hb_parc( 3 )));
}

HB_FUNC( ZIPCLOSE )
{
   hb_retnl( ZipClose((HZIP) hb_parnl( 1 )));
}

HB_FUNC( UNZIPOPENFILE )
{
   HUNZIP huz;
   hb_retnl( (long) UnzipOpenFile(&huz, hb_parc( 1 ),0);  // ,0 es la  pwd
   hb_stornl((long) huz, 1 );
}

HB_FUNC( UNZIPGETITEM )
{
   HUNZIP huz = (HUNZIP) hb_parnl( 1 );
   ZIPENTRY ze;
   SYSTEMTIME stUTC;
   char lpszString[MAX_PATH];

   ZeroMemory( &ze, sizeof( ZIPENTRY ));

   if( hb_pcount() > 1 )
   {
     ze.Index = (DWORD) hb_parni( 2 );
   }

   UnzipGetItem( huz, &ze );

   hb_reta( 7 );
   hb_stornl( (long) &ze,          -1, 1 );
   hb_storni( (int) ze.Index,      -1, 2 );
   hb_storni( (int) ze.Attributes, -1, 3 );

   FileTimeToSystemTime(&ze.ModifyTime,&stUTC);
   wsprintf(lpszString, "%02d/%02d/%d  %02d:%02d", stUTC.wDay, stUTC.wMonth, stUTC.wYear, stUTC.wHour, stUTC.wMinute);

   hb_storc( lpszString,           -1, 4 );
   hb_stornl( ze.CompressedSize,   -1, 5 );
   hb_stornl( ze.UncompressedSize, -1, 6 );
   hb_storc( ze.Name,              -1, 7 );

}

HB_FUNC( UNZIPITEMTOFILE )
{
   HUNZIP huz = (HUNZIP) hb_parnl( 1 );
   UnzipItemToFile( huz, hb_parc( 2 ), (ZIPENTRY*) hb_parnl( 3 ) );
   hb_ret();
}

HB_FUNC( UNZIPCLOSE )
{
   UnzipClose( (HUNZIP) hb_parnl( 1 ));
   hb_ret();
}





/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////









HB_FUNC ( CGETFILEEX )   
{
        OPENFILENAME ofn;
        char buffer[65536];
        char cFullName[64][1024];
        char cCurDir[512];
        char cFileName[512];
        int iPosition = 0;
        int iNumSelected = 0;
        int n;
   LPSTR  pFile,pFilter,pTitle,pDir;
   WORD w = 0, wLen;
        int flags =  OFN_ALLOWMULTISELECT | OFN_EXPLORER ; // | OFN_FILEMUSTEXIST

        buffer[0] = 0 ;

   // alloc for title

   pTitle = ( LPSTR ) hb_xgrab( 128 );

   if ( hb_pcount() > 1 && ISCHAR( 2 ) )
   {
      wLen   = min( ( unsigned long ) 127, hb_parclen( 2 ) );
      CopyMemory( pTitle, hb_parc( 2 ), wLen );
      * ( pTitle + wLen ) = 0;

   }
   else
   {
      pTitle  = Title;
   }

   // alloc for initial dir

   pDir = ( LPSTR ) hb_xgrab( 128 );

   if ( hb_pcount() > 3 && ISCHAR( 4 ) )
   {
      wLen  = min( ( unsigned long ) 127, hb_parclen( 4 ) );
      CopyMemory( pDir, hb_parc( 4 ), wLen );
      * ( pDir + wLen ) = 0;
   }
   else
   {
      * ( pDir ) = 0;
   }

   // alloc for file

   pFile = ( LPSTR ) hb_xgrab( 255 );

   if ( hb_pcount() > 7 && ISCHAR( 8 ) )
   {
      wLen = min( ( unsigned long ) 254, hb_parclen( 8 ) );
      CopyMemory( pFile, hb_parc( 8 ), wLen );
   }
   else
   {
      wLen = min( ( unsigned long ) 254, hb_parclen( 1 ) );
      CopyMemory( pFile, hb_parc( 1 ), wLen );
   }
   * ( pFile + wLen ) = 0;

   // alloc for mask

   pFilter = ( LPSTR ) hb_xgrab( 400 );
   wLen    = min( ( unsigned long ) 398, hb_parclen( 1 ) );
   CopyMemory( pFilter, hb_parc( 1 ), wLen );
   * ( pFilter + wLen ) = 0;

   #ifndef __FLAT__
   //   _xunlock();
   #endif

   while( * ( pFilter + w ) )
   {
      if( * ( pFilter + w ) == '|' )
      {
         * ( pFilter + w ) = 0;
         if ( hb_pcount() < 8 )
            * (pFile) = 0;
      }
      w++;
   }

   * ( pFilter + wLen  ) = 0;
   * ( pFilter + wLen + 1 ) = 0;

   if( hb_pcount() == 8 )
     strcpy( buffer, hb_parc(8));

        memset( (void*) &ofn, 0, sizeof( OPENFILENAME ) );
        ofn.lStructSize = sizeof(ofn);
        ofn.hwndOwner = GetActiveWindow();
        ofn.lpstrFilter = pFilter;
        ofn.nFilterIndex = 1;
        ofn.lpstrFile = buffer;
        ofn.nMaxFile = sizeof(buffer);
        ofn.lpstrInitialDir = hb_parc(3);
        ofn.lpstrTitle = pTitle;
        ofn.nMaxFileTitle = 512;
        ofn.Flags = flags;

        if( GetOpenFileName( &ofn ) )
        {
                if(ofn.nFileExtension!=0)
                {
                        hb_retc( ofn.lpstrFile );
                }
                else
                {
                        wsprintf(cCurDir,"%s",&buffer[iPosition]);
                        iPosition=iPosition+strlen(cCurDir)+1;

                        do
                        {
                                iNumSelected++;
                                wsprintf(cFileName,"%s",&buffer[iPosition]);
                                iPosition=iPosition+strlen(cFileName)+1;
                                wsprintf(cFullName[iNumSelected],"%s\\%s",cCurDir,cFileName);
                        }
                        while(  (strlen(cFileName)!=0) && ( iNumSelected <= 63 ) );

                        if(iNumSelected > 1)
                        {
                                hb_reta( iNumSelected - 1 );

                                for (n = 1; n < iNumSelected; n++)
                                {
                                        hb_storc( cFullName[n], -1, n );
                                }
                        }
                        else
                        {
                                hb_retc( &buffer[0] );
                        }
                }
        }
        else
        {
                hb_retc( "" );
        }
}

// del msdn
INT CALLBACK BrowseCallbackProc(HWND hwnd,
                                UINT uMsg,
                                LPARAM lp,
                                LPARAM pData)
{
   switch(uMsg)
   {
   case BFFM_INITIALIZED:
      if (szDirName)
      {
         // WParam is TRUE since you are passing a path.
         // It would be FALSE if you were passing a pidl.
         SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDirName);
      }
      break;
   }
   return 0;
}









#pragma ENDDUMP




/*
prueba.rc

IDD_ABOUTBOX DIALOG 61, 128, 572, 280
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Zip - UnZip"
FONT 8, "MS Sans Serif"
{
LTEXT "Fichero de origen:", -1, 16, 17, 104, 8
EDITTEXT 101, 16, 30, 242, 14, ES_AUTOHSCROLL
PUSHBUTTON "...", 102, 262, 30, 16, 14
LISTBOX 103, 16, 54, 242, 140, LBS_STANDARD
PUSHBUTTON "Abrir", 104, 210, 203, 50, 14
LTEXT "Fichero de destino:", -1, 299, 17, 104, 8
EDITTEXT 105, 299, 30, 242, 14, ES_AUTOHSCROLL
PUSHBUTTON "...", 106, 545, 30, 16, 14
LISTBOX 107, 299, 54, 242, 140, LBS_STANDARD
PUSHBUTTON "...", 108, 545, 177, 16, 14
PUSHBUTTON "Comprimir", 109, 492, 203, 50, 14
CONTROL "", 110, "TMeter", 0 | WS_CHILD | WS_VISIBLE, 17, 229, 520, 3
DEFPUSHBUTTON "OK", 1, 492, 256, 50, 14
}

*/


En los ficheros hay uno en concreto que arroja algo de luz, a falta de documentación es "vb.txt" donde indica mas o menos lo que recibe cada parámetro.

Yo lo he enlazado con VC.

Hay que enlazar las libs correspondientes para poder llamar a las funciones de la dll

Si estais con Borland, creo que se pueden sacar las libs de una dll con implib. Esto no lo tengo muy seguro.

Creo que esto solucionaría en gran parte el problema de harbour con los zips.

Un saludo


[/url]
User avatar
Paco Garcia
 
Posts: 172
Joined: Fri Oct 07, 2005 12:00 pm

Por cierto

Postby Paco Garcia » Tue Oct 24, 2006 4:36 pm

Por cierto, me ha parecido entender que habia version para Windows CE
User avatar
Paco Garcia
 
Posts: 172
Joined: Fri Oct 07, 2005 12:00 pm

Postby cmsoft » Wed Oct 25, 2006 10:43 am

Gracias Paco y Manuel, pruebo ambos y luego les cuento.
User avatar
cmsoft
 
Posts: 1189
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

rectificación de la función UnzipClose

Postby Paco Garcia » Tue Nov 07, 2006 9:05 am

Donde puse:

UnzipClose()

debe decir

UnzipClose( hUnz )

si no es asi irá perdiendo memoria porque la dll no puede liberar lo que se pillo en el Open

Por lo demas he comprobado que funciona a las mil maravillas
User avatar
Paco Garcia
 
Posts: 172
Joined: Fri Oct 07, 2005 12:00 pm

Postby JmGarcia » Tue Nov 04, 2008 12:11 pm

Antonio Linares wrote:Esas funciones de FW no están disponibles en 32 bits.
Tienes que usar la librería hbzip.lib de xharbour. Tienes ejemplos de uso en xharbour\tests

Pues si uso HBZIP.LIB me da estos errores:
Code: Select all  Expand view
Error: Unresolved external '_inflateEnd' referenced from C:\BASES\FWH0810\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_deflate' referenced from C:\BASES\FWH0810\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_get_crc_table' referenced from C:\BASES\FWH0810\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_deflateEnd' referenced from C:\BASES\FWH0810\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_deflateInit2_' referenced from C:\BASES\FWH0810\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_crc32' referenced from C:\BASES\FWH0810\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_inflateInit2_' referenced from C:\BASES\FWH0810\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_inflate' referenced from C:\BASES\FWH0810\XHARBOUR\LIB\HBZIP.LIB|ziparchive


Si no uso esa LIB me da este error:
Code: Select all  Expand view
Error: Unresolved external '_HB_FUN_HB_ZIPFILE' referenced from C:\PROGRAMA\AUTOFTP\OBJ\AUTOFTP.OBJ


La función que uso es HB_ZIPFILE(cFichZIP,aFiles[Indice])

¿ Que hago ?
¿ Como se soluciona ?
Mi abuelo decía: Los aviones vuelan porque Dios quiere, y los helicópteros ni Dios sabe porque vuelan.
FWH 16.02, xHarbour 1.2.3, Harbour 3.2.0, WorkShop 4.5, AJ Make 0.30, Borlan BCC 7.00, VisualStudio 2013
User avatar
JmGarcia
 
Posts: 654
Joined: Mon May 29, 2006 3:14 pm
Location: Madrid - ESPAÑA


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 84 guests