/*
 * $DOC$
 * $FUNCNAME$
 *      HB_ZIPFILE()
 * $CATEGORY$
 *      ZIP FUNCTION
 * $ONELINER$
 *      Create a zip file
 * $SYNTAX$
 *      HB_ZIPFILE( <cFile> , <cFileToCompress> | <aFiles>, <nLevel> ,
 *      <bBlock>,<lOverWrite> ) ---> lCompress
 * $ARGUMENTS$
 *      <cFile>   Name of the zip file
 *
 *      <cFileToCompress>  Name of a file to Compress, Drive and/or path
 *      can be used
 *
 *      <aFiles>  An array containing files to compress, Drive and/or path
 *      can be used
 *
 *      <nLevel>  Compression level ranging from 0 to 9
 *
 *      <bBlock>  Code block to execute while compressing
 *
 *      <lOverWrite>  Toggle to overwite the file if exists
 * $RETURNS$
 *      <lCompress>  .t. if file was create, otherwise .f.
 * $DESCRIPTION$
 *      This function creates a zip file named <cFile>. If the extension
 *      is ommited, .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 detemines the compression type where 0 means
 *      no compression and 9 means best compression.
 *
 *      If <bBlock> 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.
 * $EXAMPLES$
 *      FUNCTION MAIN()
 *
 *      IF HB_ZIPFILE( "TEST.ZIP","TEST.PRG") 
 *         qout("File was successly create")
 *      ENDIF
 *
 *      IF HB_ZIPFILE( "TEST1.ZIP",{"TEST.PRG","c:\windows\win.ini"}) 
 *         qout("File was successly create")
 *      ENDIF
 *
 *      IF HB_ZIPFILE( "TEST2.ZIP",{"TEST.PRG","c:\windows\win.ini"},8,{|nPos,cFile|,qout(cFile)}) 
 *         qout("File was successly create")
 *      ENDIF
 *
 *      aFiles := {"TEST.PRG","c:\windows\win.ini"}
 *      nLen   := Len(afiles)
 *      aGauge := GaugeNew( 5, 5, 7,40 , "W/B", "W+/B" ,'')
 *      GaugeDisplay( aGauge )                                            
 *      Hb_ZIPFILE('test33.zip',aFiles,8,{|cFile,nPos| GaugeUpdate(aGauge,nPos/nLen)})
 *      Return Nil
 * $STATUS$
 *      R
 * $COMPLIANCE$
 *      This function is a Harbour extension
 * $PLATFORMS$
 *      All
 * $FILES$
 *      Library is zlib.lib and zlib_bor.lib For Borland Compilers
 *      Library is zlib.lib zlib_ms.lib for MSVC compilers
 * $END$
 */ 

/*
 * $DOC$
 * $FUNCNAME$
 *      HB_UNZIPFILE()
 * $CATEGORY$
 *      ZIP FUNCTION
 * $ONELINER$
 *      Unzip a compressed file
 * $SYNTAX$
 *      HB_UNZIPFILE( <cFile> , <bBlock> , <lWithPath>) ---> lCompress
 * $ARGUMENTS$
 *      <cFile>   Name of the zip file
 *
 *      <bBlock>  Code block to execute while compressing
 *
 *      <lWithPath> Toggle to create directory if needed
 *
 * $RETURNS$
 *      <lCompress>  .t. if all file was successfuly restored, otherwise .f.
 * $DESCRIPTION$
 *      This function restores all files contained inside the <cFile>.
 *      If the extension is ommited, .ZIP will be assumed. If a file already 
 *      exists, it wlll be overwriten.
 *
 *      If <bBlock> is used, every time the file is opened to compress it
 *      will evaluate bBlock. Parameters of bBlock are cFile and nPos.
 * $EXAMPLES$
 *      FUNCTION MAIN()
 *
 *      IF HB_UNZIPFILE( "TEST.ZIP") 
 *         qout("File was successly create")
 *      ENDIF
 *
 *      IF HB_ZIPFILE( "TEST2.ZIP",{|cFile|,qout(cFile)}) 
 *         qout("File was successly create")
 *      ENDIF
 *
 *      Return Nil
 * $STATUS$
 *      R
 * $COMPLIANCE$
 *      This function is a Harbour extension
 * $PLATFORMS$
 *      All
 * $FILES$
 *      Library is zlib.lib and zlib_bor.lib For Borland Compilers
 *      Library is zlib.lib zlib_ms.lib for MSVC compilers
 * $END$
 */ 

/*
 * $DOC$
 * $FUNCNAME$
 *      HB_GETUNZIPFILE()
 * $CATEGORY$
 *      ZIP FUNCTION
 * $ONELINER$
 *      Gets the number of files that are in the zipfile
 * $SYNTAX$
 *      HB_GETUNZIPFILE( <cFile>) ---> nNumber
 * $ARGUMENTS$
 *      <cFile>   Name of the zip file
 * $RETURNS$
 *      <nNumber>  The number of files contained inside the zipfile
 * $DESCRIPTION$
 *      This function returns the number of files that is stored in the zipfile.
 *      The purpose for this function is to use in conjuntion with the
 *      HB_UNZIPFILE() function, so you can use returned result in the code
 *      block. See example below.
 * $EXAMPLES$
 *      FUNCTION MAIN()
 *      Local nFiles :=HB_GETUNZIPFILE('test.zip')
 *
 *      if nFiles >0
 *         ? "This files Contains ",nfiles
 *      endif
 *
 *      Return Nil
 *
 *      Here is an example of How to use HB_GETUNZIPFILE() in conjunction
 *      with HB_UNZIPFILE()
 *
 *      Function Main()
 *      Local aGauge,nLen
 * 
 *      aGauge := GaugeNew( 5, 5, 7,40 , "W/B", "W+/B" ,'')
 *      GaugeDisplay( aGauge )
 *      nLen := HB_GETUNZIPFILE('test22')
 *      hb_UNZIPFILE('test22',{|cFile,nPos| GaugeUpdate(aGauge,nPos/nLen),qout(cFile)},.t.)
 *
 *      Return Nil      
 * $STATUS$
 *      R
 * $COMPLIANCE$
 *      This function is a Harbour extension
 * $PLATFORMS$
 *      All
 * $FILES$
 *      Library is zlib.lib and zlib_bor.lib For Borland Compilers
 *      Library is zlib.lib zlib_ms.lib for MSVC compilers
 * $END$
 */ 

