Page 1 of 2

HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Tue Feb 24, 2009 4:11 am
by dutch
Dear All,

I've searched in the forum about this topic and it has many options and many solutions. I would like to know what exactly need for ZIP/UNZIP for Harbour/xHarbour (FTDN). Because I think many people ask this question many time.

- Which does library need for Harbour and xHarbour (FTDN)?
- Which DLL need for each?
- Samples?

Any help are appreciated.

Thanks in advance for kindly help,
Dutch

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Tue Feb 24, 2009 8:41 am
by StefanHaupt
Dutch,

you must link hbzip.lib.

You can use hb_ZipFile() and hb_UnzipFile ().

Code: Select all  Expand view
lOk := hb_ZipFile( ::cTarget  , ;
                           aFiles , ;
                           ::nCompress , ;
                           bZip  , ;
                           ::lOverwrite , ;           // overwrite
                           ::cPassword  , ;
                           ::lWithPath,;               // with path
                           ::lWithDrive  )

lOk := hb_UnZipFile( ::cZip        , ;
                            bOnUnZipFile  , ;
                            ::lWithSubDir   , ;
                            ::cPassword     , ;
                            ::cZipDir + "\" ,;
                            ::aFiles        ,;
                            ::bProgress)

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Tue Feb 24, 2009 9:08 am
by dutch
Dear Stefan,

I've in xHarbour\Lib but it is not compatible with Harbour. It has no in Harbour\Lib.
Where can I get it?
Have I need to link HBZLIB.LIB too?

StefanHaupt wrote:Dutch,

you must link hbzip.lib.

You can use hb_ZipFile() and hb_UnzipFile ().



Regards,
Dutch

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Tue Feb 24, 2009 9:51 am
by Antonio Linares
Dutch,

Maybe you should consider to migrate to xharbour, as it may be easier for you.

In Harbour there are less users and the programmers needs to be more experienced with Harbour itself.

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Tue Feb 24, 2009 9:54 am
by Antonio Linares
Dutch,

Here you have hbzlib.lib for Harbour:
http://www.mediafire.com/?sharekey=414c ... 0a1ae8665a

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Tue Feb 24, 2009 10:05 am
by dutch
Dear Antonio,

I think so, because I've found almost use xHarbour and it has more features than Harbour.
I try ZIPFILE with xHarbour, it's ok.

Antonio Linares wrote:Dutch,

Maybe you should consider to migrate to xharbour, as it may be easier for you.

In Harbour there are less users and the programmers needs to be more experienced with Harbour itself.


Regards,
Dutch

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Sat Nov 28, 2009 6:58 am
by anserkk
I am using xHarbour. I modified the Buildx.Bat and added the lib hbzip.lib unfortunately I get so many errors

Code: Select all  Expand view
Turbo Incremental Link 5.00 Copyright (c) 1997, 2000 Borland
Error: Unresolved external '_inflateEnd' referenced from D:\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_deflate' referenced from D:\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_get_crc_table' referenced from D:\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_deflateEnd' referenced from D:\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_deflateInit2_' referenced from D:\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_crc32' referenced from D:\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_inflateInit2_' referenced from D:\XHARBOUR\LIB\HBZIP.LIB|ziparchive
Error: Unresolved external '_inflate' referenced from D:\XHARBOUR\LIB\HBZIP.LIB|ziparchive
* Linking errors *
 

Is there any linking order of hbzip lib. In the buildx.bat, I have linked the lib hbzip lib as the last xHarbour lib (just before the commands to link Borland libs)


Code: Select all  Expand view
echo %hdirl%\pcrepos.lib + >> b32.bc
echo %hdirl%\hbzip.lib + >> b32.bc

rem Uncomment these two lines to use Advantage RDD
rem echo %hdir%\lib\rddads.lib + >> b32.bc
rem echo %hdir%\lib\Ace32.lib + >> b32.bc

echo %bcdir%\lib\cw32.lib + >> b32.bc
echo %bcdir%\lib\import32.lib + >> b32.bc


Code: Select all  Expand view
*------------------------------------*
Function ExtractZip(cDriveLetter)
*------------------------------------*
Local aFiles,lOk
// Zip and Unzip functions, should include the lib named zlib available in \xHarbour\lib
aFiles := hb_GetFilesInZip("Test.Zip")
lOk := hb_unzipfile(cFile,,,,cDriveLetter,aFiles,NIL)
Return
 


Regards
Anser

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Sat Nov 28, 2009 9:46 am
by Antonio Linares
Anser,

You have to link zlib.lib also

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Sat Nov 28, 2009 9:52 am
by anserkk
Solved the Linking error.

You need to add xHarbour libs ZLib.lib and HbZip.Lib.

There are no runtime errors, but I am unable to extract the Zip file contents.

Code: Select all  Expand view
*------------------------------------*
Function ExtractZip()
*------------------------------------*
Local aFiles,lOk
// Zip and Unzip functions, should include the lib named zlib and HbZip libs available in \xHarbour\lib
aFiles := hb_GetFilesInZip("Test.Zip")  // ValType of aFiles is NIL
lOk := hb_unzipfile("Test.Zip,,,,"F:\",aFiles,NIL)  // No Errors but not functioning
Return


The "Test.Zip" is created using WinZip and is zip of of a directory containing multiple ( 4 to 5) directories
Any hints ?

Regards
Anser

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Sat Nov 28, 2009 10:02 am
by anserkk
Sorry it was my mistake. I had problem with the Zip files Path.

If you need to extract zip file with the Path details then the 3rd Parameter should be .T.
lOk := hb_unzipfile("E:\Test.Zip",,.T.,,"F:\",aFiles,NIL)

It is working fine

Regards
Anser

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Sat Nov 28, 2009 10:05 am
by Antonio Linares
Anser,

very good :-)

many thanks for your feedback

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Sat Jun 19, 2010 6:34 am
by fraxzi
anserkk wrote:...
If you need to extract zip file with the Path details then the 3rd Parameter should be .T.
lOk := hb_unzipfile("E:\Test.Zip",,.T.,,"F:\",aFiles,NIL)

It is working fine
...


Dear Mr. Anser,

I successfully zipped a file using:
Code: Select all  Expand view

...
HB_ZipFile('file.zip',{'filetozip.txt'}, {|cFile, nPos| oSay1:SetText( cFile ) },.T.,,,{|nBytes, nSize| oSay2:SetText(cValToChar(nBytes)+'/'+cValToChar(nsize)) })    //return .T. and zip file created.
...
aFiles := HB_GetFilesInZip( 'file.zip' )
...
HB_UnZipFile( 'file.zip' ,,.T.,,".\",aFiles, Nil )  //return .F. and file not unzipped., even if I used absolute paths 'd:\file.zip'... 'd:'...


Still cannot unzip with HB_UnzipFile()...

Im using FWH10.5, BCC582 and XHB 1.21.5714... added library hbzip.lib and zlib.lib


Regards,
Frances

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Sat Jun 19, 2010 8:11 am
by fraxzi
Dear All,

Using HB_UnZipFile( 'File.Zip', , , , , "*.*") successfully extracted the content of 'file.zip', HOWEVER, the return value is always .F... but successfully done the decompression..

BUG?


Regards,
Frances

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Wed Jun 30, 2010 4:32 am
by fraxzi
Dear All,

nobody experienced this on BCC582 and FWH 10.6?


Regards,
Frances

Re: HB_ZIPFILE() & HB_UNZIPFILE() for Harbour/xHarbour (FTDN)?

PostPosted: Wed Jun 30, 2010 6:11 am
by anserkk
Dear Mr.Frances,

The below given code is working fine for me.

hb_unzipfile("Apps.Zip",,.T.,,cExtractToPath,aFiles,NIL) returned .T. for me

I have used FWH 10.6 Buildx.bat to compile and run the test.

Code: Select all  Expand view
#include "Fivewin.ch"
//----------------------------//
Function Main()
    Local oDlg,oBtn
   
    DEFINE DIALOG oDlg TITLE "Test UnZip"
   
    @1,5 BUTTON oBtn PROMPT "Unzip" ;
         ACTION MsgInfo( If(ExtractZip("D:\MyTest\"),"OK","Not OK") ) // Returned .T.

    ACTIVATE DIALOG oDlg

Return NIL

*------------------------------------*
Function ExtractZip(cExtractToPath)
*------------------------------------*
Local aFiles,lOk
// Zip and Unzip functions, should include the libs named HbZip & zlib available in \xHarbour\lib

// Array containing the list of files in the Zip with Path
aFiles := hb_GetFilesInZip("
Apps")

// The 3rd Parameter should be .T. if you need to extract contents of zip file as per Path
lOk := hb_unzipfile("
Apps",,.T.,,cExtractToPath,aFiles,NIL)
Return lOk


The contents of the zip file (Apps.zip) was properly extracted inside the folder D:\MyTest
I suggest you to check the path

Regards

Anser