# HB_ZIPFILEBYTDSPAN()

Create a zip file

Syntax

  HB_ZIPFILEBYTDSPAN()( <cFile> , <cFileToCompress> | <aFiles>, <nLevel> ,
  <bBlock>,<lOverWrite> ,<cPassword>,<iSize>,<lWithPath>,<lWithDrive>) ---> 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
  <cPassword> Password to encrypt the files
  <iSize> Size of the archive, in bytes,default is 1457664 bytes
  <lWithPath> Toggle to store the path or not
  <lWithDrive> Toggle to store the Drive letter and path or not

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,otherwise if <lOverWrite> is false the new files are added to the <cFile>.
  If <lWithPath> is used, it tells thats 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.

Examples

          FUNCTION MAIN()

          IF HB_ZIPFILEBYTDSPAN( "TEST.ZIP","TEST.PRG")
             qout("File was successly create")
          ENDIF

          IF ZIPFILEBYTDSPAN( "TEST1.ZIP",{"TEST.PRG","c:\windows\win.ini"})
             qout("File was successly create")
          ENDIF

          IF HB_ZIPFILEBYTDSPAN( "TEST2.ZIP",{"TEST.PRG","c:\windows\win.ini"},8,{|nPos,cFile|,qout(cFile)},'hello',,521421)
             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_ZIPFILEBYTDSPAN('test33.zip',aFiles,8,{|cFile,nPos| GaugeUpdate(aGauge,nPos/nLen)},,'hello',,6585452)
          Return Nil

Status

  Ready

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