Jump to content
Fivewin Brasil

Hb_ZipFile nao Funciona


megatron

Recommended Posts

Ola a funcão Hb_zipfile, faz o processamento termina, mas nao compacta, alguem pode me ajudar??

Fonte:

#include fivewin.ch

Function Backupdbf()

d_nom="c:\megatron\copias\GEFIN"+SONUM(DTOS(DATE())+TIME())+".ZIP"

d_nom:=cGetFile(d_nom, "Selecione o Arquivo" )

if msgyesno("Confirma")

DECLARE m_arq[ADIR("*.DBF")]

l_qtd=ADIR("*.DBF",m_arq)

HB_zipfile(d_nom,m_arq)

Msginfo("Processo Finalizado")

endif

Release d_nom,w_bkp

Return .t.

Editado por - megatron on 06/03/2009 14:36:00

Editado por - megatron on 06/03/2009 14:37:21

Link to comment
Share on other sites

Ola a funcão Hb_zipfile, faz o processamento termina, mas nao compacta, alguem pode me ajudar??

Fonte:

#include fivewin.ch

Function Backupdbf()

d_nom="c:\megatron\copias\GEFIN"+SONUM(DTOS(DATE())+TIME())+".ZIP"

d_nom:=cGetFile(d_nom, "Selecione o Arquivo" )

if msgyesno("Confirma")

DECLARE m_arq[ADIR("*.DBF")]

l_qtd=ADIR("*.DBF",m_arq)

HB_zipfile(d_nom,m_arq)

Msginfo("Processo Finalizado")

endif

Release d_nom,w_bkp

Return .t.

Editado por - megatron on 06/03/2009 14:36:00

Editado por - megatron on 06/03/2009 14:37:21

Link to comment
Share on other sites

HB_ZIPFILE() //Create a zip file

SYNTAX : HB_ZIPFILE( , | , , , , , , , ) ---> lCompress

ARGUMENTS

Name of the zip file to create

Name of a file to Compress, Drive and/or path can be used

_or_ An array containing files to compress, Drive and/or path can be used

Compression level ranging from 0 to 9

Code block to execute while compressing

Toggle to overwrite the file if exists

Password to encrypt the files

Toggle to store the path or not

Toggle to store the Drive letter and path or not

Code block for File Progress

RETURNS : .t. if file was create, otherwise .f.

DESCRIPTION : This function creates a zip file named . 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 will be compressed.

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

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

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

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

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

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

If 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

MSN: samirid=red>abreuid=black>@hotmail.com

Skype: Samirid=red>Abreuid=black>

xHarbour 1.1.0 + FwXh 8.02

Link to comment
Share on other sites

Samir me desculpe amigo, mas amigo não esta querendo como se usa o comando e sim resolver um problema que até hoje ainda não consegui resolver também, e o meu sai do programa e cria o arquivo compactado com apenas 1kb

Já coloquei a HBZIP e a ZLIB antes das do Fivewin, já atualizei o xHarbour para 1.1.0 (simplex) e nada meu amigo!

Link to comment
Share on other sites

Ola, segue um exemplo de como utilizo.

function ZIPFILE()

LOCAL odlg,obsair,obconfirma

cNarq:="ARQDES.ZIP" // Arquivo destino

aTmpArray:={"ARQ1.DBF","ARQ2.DBF","ARQ3.DBF"} // Arquivos a serem compactados

DEFINE DIALOG odlg FROM 01,01 TO 07, 40 TITLE "Transferindo dados (Internet)"

@ 01.5,01 BUTTON obconfirma PROMPT "&Confirma" OF odlg SIZE 50, 12 ACTION ;

(obconfirma:disable(),obsair:disable(),HB_ZIPFILE("C:\APLIC\"+cnarq,atmparray,,{|CFILE| ;

strumsg( "Compactando... ",odlg) }),obsair:enable())

@ 01.5,15 BUTTON obsair PROMPT "&Sair" OF odlg SIZE 50, 12 ACTION (odlg:End())

ACTIVATE DIALOG odlg centered

RETURN nil

Link to comment
Share on other sites

Fiz uma nova alteração no codigo, mas mesmo assim nao funciona. Alguem pode me ajudar ai? esta solução servirá pra muita gente.

Function Backupdbf()

d_bkpnom="c:\megatron\copias\GEFIN"+SONUM(DTOS(DATE())+TIME())+".ZIP"

d_bkpnom:=cGetFile(d_bkpnom, "Selecione o Arquivo" )

if msgyesno("Confirma")

l_bkpsai=fcreate(d_bkpnom)

if l_bkpsai<=0

msginfo("Nao foi possivel criar o arquivo")

Return .f.

endif

DECLARE m_bkparq[ADIR("*.DBF")]

l_bkpqtd=ADIR("*.DBF",m_bkparq)

l_bkpdir:=curdir()+"\"

l_bkpdrv:=curdrive()+":\"

l_bkparq:={}

if l_bkpqtd<=0

MsgInfo("Arquivos nao existem")

Return .f.

endif

for bkp_n=1 to l_bkpqtd

aadd(l_bkparq,l_bkpdrv+l_bkpdir+alltrim(m_bkparq[bkp_n]))

next

close all

l_bkpsai=fopen(l_bkparq[1],0)

if l_bkpsai<=0

msginfo("Nao foi possivel abrir o arquivo")

Return .t.

endif

fclose(l_bkpsai)

HB_zipfile(d_bkpnom,l_bkparq,,{|CFILE|msgrun( "Compactando... ") })

Msginfo("Processo Finalizado")

endif

Link to comment
Share on other sites

Megatron,o fato não é a rotina, fiz uns testes e ele apenas compacta 3 aquivos, parace quano o ARRAY é grande demais ele da problema, eu ainda não consegui entender este problema já que tenho o XB 1.1.0 (simplex)

alguém tem a versão anterior para mandar pra este e-mail..

ladinilson@hotmail.com

queria testar se é problema de versão!

Link to comment
Share on other sites

Bom dia!

Pesquisando no site internacional e com a ajuda de colegas aqui do forum estou usando a compactação de dados sem problemas.

Segue a solução:


Para compactar:

********************

Function zipCreate()

********************

Local lRet, adir

afiles := {}

aDir := Directory( "*.dbf" )

Aeval( aDir, {|a| aadd( aFiles, a[1]) })

aDir := Directory( "*.inf" )

Aeval( aDir, {|a| aadd( aFiles, a[1]) })

ferase('compact.zip')

lRet := hb_zipfile( 'compact.zip', afiles ) // HB_ZIPFILE( 'compact.zip', afiles, , , .t.,, .f.,,)

Return lRet

Para Descompactar:

aFiles := hb_GetFilesInZip( cArqZip, .T. )

aExtract := {}

AEval( aFiles, {|e| AAdd( aExtract, e[ 1 ] ) } )

lok := HB_UNZIPFILE( cArqZip ,,,,CurDrive()+':'+CurDir(), aExtract )

id=code>id=code>

Lembrando que essa solução funciona para o xharbour 1.0.0, em versões anteriores não sei se funciona.

Espero que ajude!

t+

FWXH 9.01, PELLESC, MYMAKE 1.9J, DBF

Belzonte - Minas Gerais

Link to comment
Share on other sites

A versão 1.0.0 beta1 do xharbour voce pode baixar em www.xharbour.org, mas se voce usa com o fivewin voce tem que usar com a versão do xharbour que veio com ele, de outra forma não sei como proceder.

t+

FWXH 9.01, PELLESC, MYMAKE 1.9J, DBF

Belzonte - Minas Gerais

Link to comment
Share on other sites

Megatron como já percebeu, tenho este mesmo problema, peguei um exemplo mas este usa a xHbzip.dll que é do xHB comercial e deu um erro, continuo também neste calvário e acho que só nos mesmos estamos neste barco já que muitos não tem este problema e também não sei porque já que meu xHB é 1.1.0 (simplex)

queria pedir aos colegas que não estão com este problema, que me enviassem a HBZIP.LIB e a ZLIB.LIB para meu email...

ladinilson@hotmail.com

para fazer os testes

Obrigado

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...