hb_zipfile - pastas
Moderador: Moderadores
-
TerraSoftware
- Usuário Nível 3

- Mensagens: 353
- Registrado em: 28 Jul 2004 13:14
- Localização: Cianorte-PR
- Contato:
hb_zipfile - pastas
Caros colegas, já utilizo a funcao hb_zipfile para compactar arquivos no formato zip a algum tempo e ela tem funcionado muito bem, mas agora preciso compactar pastas, subpastas e seus conteudos e tambem descompactalas todas com a mesma estrutura, alguem pode me ajudar neste sentido?
- sygecom
- Administrador

- Mensagens: 7131
- Registrado em: 21 Jul 2006 10:12
- Localização: Alvorada-RS
- Contato:
Re: hb_zipfile - pastas
Veja que no documentação das funções ZIP, tem opção para guardar o caminho do aruqivo veja abaixo:
Sendo assim acredito que seja mais fácil mandar compactar e descompactar o mesmo com suas pasta origem e destino./*
* $DOC$
* $FUNCNAME$
* HB_ZIPFILE()
* $CATEGORY$
* Zip Functions
* $ONELINER$
* Create a zip file
* $SYNTAX$
* HB_ZIPFILE( <cFile>, <cFileToCompress> | <aFiles>, <nLevel>,
* <bBlock>, <lOverWrite>, <cPassword>, <lWithPath>, <lWithDrive>,
* <pFileProgress> ) ---> lCompress
* $ARGUMENTS$
* <cFile> Name of the zip file to create
*
* <cFileToCompress> Name of a file to Compress, Drive and/or path
* can be used
* _or_
* <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 overwrite the file if exists
*
* <cPassword> Password to encrypt the files
*
* <lWithPath> Toggle to store the path or not
*
* <lWithDrive> Toggle to store the Drive letter and path or not
*
* <pFileProgress> Code block for File Progress
* $RETURNS$
* <lCompress> .t. if file was create, otherwise .f.
* $DESCRIPTION$
* 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 <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 <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 <pFileProgress> 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))}
*
* $EXAMPLES$
* FUNCTION MAIN()
*
* IF HB_ZIPFILE( "TEST.ZIP", "TEST.PRG" )
* qout( "File was successfully created" )
* ENDIF
*
* IF HB_ZIPFILE( "TEST1.ZIP", { "TEST.PRG", "c:\windows\win.ini" } )
* qout( "File was successfully created" )
* ENDIF
*
* IF HB_ZIPFILE( "TEST2.ZIP", { "TEST.PRG", "c:\windows\win.ini" }, 9, {|cFile,nPos,| qout(cFile) } )
* qout( "File was successfully created" )
* 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, 9, {|cFile,nPos| GaugeUpdate( aGauge, nPos/nLen ) },, "hello" )
* Return Nil
* $STATUS$
* R
* $COMPLIANCE$
* This function is a Harbour extension
* $PLATFORMS$
* All
* $FILES$
* Library is hbzip.lib
* $END$
*/
Leonardo Machado
xHarbour.org + Hwgui + PostgreSql
xHarbour.org + Hwgui + PostgreSql