FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Archivos ZIP en Harbour 3.2
Posts: 476
Joined: Sat Feb 03, 2007 06:36 AM
Archivos ZIP en Harbour 3.2
Posted: Fri Mar 13, 2015 05:23 PM
Hola a todos.
Estoy intentando hacer una rutina para comprimir archivos, utilizando la funcion HB_ZipFile, con Harbour 3.2

Pero tengo estos errores al momento de enlacer el proyecto:
Code (fw): Select all Collapse
 Error: Unresolved external '_HB_FUN_HB_ZIPFILE'  
Error: Unresolved external '_HB_FUN_HB_UNZIPFILE'

Estoy enlazando las librerias HbZlib y HbmZip

Si agrego la libreria HbZipArc, obtengo mucho mas errores como este:
Code (fw): Select all Collapse
Error: Unresolved external '_zipOpen2' referenced from G:\HARBOUR3.2\LIB\HBMZIP.LIB|mzip
Error: Unresolved external '_unzGetOffset' referenced from G:\HARBOUR3.2\LIB\HBMZIP.LIB|mzip
Error: Unresolved external '_unzSetOffset' referenced from G:\HARBOUR3.2\LIB\HBMZIP.LIB|mzip
Error: Unresolved external '_zipCloseFileInZip' referenced from G:\HARBOUR3.2\LIB\HBMZIP.LIB|mzip
Error: Unresolved external '_unzOpenCurrentFilePassword' referenced from G:\HARBOUR3.2\LIB\HBMZIP.LIB|mzip
....


Que estoy haciendo mal?
Que librería me hace falta incluir?

Por favor si alguien puede darme alguna ayuda con esto.

Gracias.

Carlos.
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Archivos ZIP en Harbour 3.2
Posted: Fri Mar 13, 2015 05:30 PM
http://www.mail-archive.com/harbour@harbour-project.org/msg04839.html


Code (fw): Select all Collapse
hbmzip.lib e minizip.lib

talvez también:

 HBZipArc.Lib


Saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Archivos ZIP en Harbour 3.2
Posted: Fri Mar 13, 2015 05:32 PM
Code (fw): Select all Collapse
#define MZIP_BUFFER_READ 1024

/*
 HB_ZIPFILE( <cFile>,
       <cFileToCompress> | <aFilesToCompress>,
       [<nLevel>],
       [<bUpdate>],
       [<lOverWrite>],
       [<cPassword>],
       [<lWithPath>],
       [<lWithDrive>],
       [<bFileUpdate>] ) --> lCompress

 This function creates a zip file named <cFile>. If the extension
 is omitted, .ZIP will be assumed. If the second parameter is a
 character string, this file will be added to the zip file. If the
 second parameter is an array, all file names contained in <aFiles>
 will be compressed.

 If <nLevel> is used, it determines the compression type where 0 means
 no compression and 9 means best compression.

 If <bUpdate> is used, every time the file is opened to compress it
 will evaluate bBlock. Parameters of bBlock are cFile and nPos.

 If <lOverWrite> is used, it toggles to overwrite or not the existing
 file. Default is to overwrite the file,otherwise if <lOverWrite> is false
 the new files are added to the <cFile>.

 If <cPassword> is used, all files that are added to the archive are encrypted
 with the password.

 If <lWithPath> is used, it tells the path should also be stored with
 the file name. Default is false.

 If <lWithDrive> is used, it tells thats the Drive and path should also be stored
 with the file name. Default is false.

 If <bFileUpdate> is used, an Code block is evaluated, showing the total
 of that file has being processed.
 The codeblock must be defined as follow {|nPos,nTotal| GaugeUpdate(aGauge1,(nPos/nTotal))}

 lWithPath and lWithDrive are not supported yet
*/

procedure HB_ZipFile( cFile, uFileToCompress, nLevel, bUpdate, lOverwrite, cPassword, lWithPath, lWithDrive, bFileUpdate, cComment )
local hZip, hHandle, nLen, cBuffer := Space( MZIP_BUFFER_READ ), cFileToZip, nPos := 1, nRead, cExt
 *if !( ".zip" $ cFile )
 * cFile += ".zip"
 *endif
 hZip = HB_ZipOpen( cFile )
 if !Empty( hZip )
   if HB_IsString( uFileToCompress )
    uFileToCompress = { uFileToCompress }
   endif
   for each cFileToZip in uFileToCompress
    if HB_IsBlock( bUpdate )
      Eval( bUpdate, cFileToZip, nPos++ )
    endif
    hHandle = FOpen( cFileToZip )
    nRead = 0
    HB_FNameSplit( cFileToZip, nil, @cFileToZip, @cExt )
    HB_ZipFileCreate( hZip, cFileToZip + cExt, nil, nil, nil, nil, nil, nLevel, cPassword, nil, nil )
    while ( nLen := FRead( hHandle, @cBuffer, MZIP_BUFFER_READ ) ) > 0
      if HB_IsBlock( bFileUpdate )
       nRead += nLen
       Eval( bFileUpdate, nRead, FSize( cFileToZip ) )
      endif
      HB_ZipFileWrite( hZip, SubStr( cBuffer, 1, nLen ), nLen )
    enddo
    FClose( hHandle )
    HB_ZipFileClose( hZip )
   next
   HB_ZipClose( hZip, cComment )
 endif
return

/*
 HB_UNZIPFILE( <cFile>,
        [<bUpdate>],
        [<lWithPath>],
        [<cPassword>],
        [<cPath>],
        [<cFile> | <aFile>],
        [<bFileUpdate>] ) --> lCompress

 <cFile>  Name of the zip file to extract

 <bUpdate> Code block to execute while extracting

 <lWithPath> Toggle to create directory if needed

 <cPassword> Password to use to extract files

 <cPath>  Path to extract the files to - mandatory

 <cFile> | <aFiles> A File or Array of files to extract - mandatory

 <bFileUpdate> Code block for File Progress

 lWithPath are not supported yet
*/

procedure HB_UnZipFile( cFile, bUpdate, lWithPath, cPassword, cPath, uFileToUnzip, bFileUpdate )
 local hUnZip, nErr, cZipName
 *if !( ".zip" $ cFile )
 * cFile += ".zip"
 *endif
 hUnZip = HB_UnZipOpen( cFile )
 if !Empty( hUnZip )
   if HB_IsString( uFileToUnzip )
    uFileToUnzip = { uFileToUnzip }
   endif
   if Empty( cPath )
    HB_FNameSplit( cFile, @cPath )
   endif
   nErr = HB_UnZipFileFirst( hUnZip )
   while nErr == 0
    if HB_UnzipFileInfo( hUnzip, @cZipName ) == 0
      if AScan( uFileToUnzip, cZipName ) > 0
       cZipName = cPath + cZipName
       HB_UnzipExtractCurrentFile( hUnZip, cZipName, cPassword
      endif
    endif
    nErr = HB_UnZipFileNext( hUnZip )
   enddo
   HB_UnZipClose( hUnZip )
 endif
return

/*
 HB_GETFILESINZIP( <cFile>, [<lExtended>] )

 <cFile>    Is the zip file to get information

 <lExtended>  Is the type of information. The default is .f. and is compatible with old ZipArch method,
         returning an array with file name only. If lExtended is TRUE, the returned array have additional 
         informations like: { cFile, dDate, cTime, nSize, nCompSize, lCrypted, cComment }
*/

function HB_GetFilesInZip( cFile, lExtended )
local hUnZip, nErr, dDate, cTime, nSize, nCompSize, lCrypted, cComment, aFiles := {}
 *if !( ".zip" $ cFile )
 * cFile += ".zip"
 *endif
 if !HB_IsLogical( lExtended )
   lExtended = .f.
 endif
 hUnZip = HB_UnZipOpen( cFile )
 if !Empty( hUnZip )
   nErr = HB_UnZipFileFirst( hUnZip )
   while nErr == 0
    HB_UnzipFileInfo( hUnzip, @cFile, @dDate, @cTime, nil, nil, nil, @nSize, @nCompSize, @lCrypted, @cComment )
    if lExtended
      AAdd( aFiles, { cFile, dDate, cTime, nSize, nCompSize, lCrypted, cComment } )
    else
      AAdd( aFiles, cFile )
    endif
    nErr = HB_UnZipFileNext( hUnZip )
   enddo
   HB_UnZipClose( hUnZip )
 endif
return aFiles
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 476
Joined: Sat Feb 03, 2007 06:36 AM
Re: Archivos ZIP en Harbour 3.2
Posted: Fri Mar 13, 2015 05:42 PM

Gracias Karinha!
Esa era la librería que me faltaba: minizip.lib

Obrigado!!

Saludos.

Carlos.

Continue the discussion