HB_ZIPFILE e HB_UNZIPFILE
Moderador: Moderadores
-
carlos_dornelas
- Usuário Nível 3

- Mensagens: 400
- Registrado em: 25 Ago 2004 21:54
HB_ZIPFILE e HB_UNZIPFILE
Amigos, alguém tem um exemplo de como incluir um diretório e seus arquivos no arquivo ZIP com o hb_zipfile do xharbour?
Antonio Carlos
Antonio Carlos
HB_ZIPFILE e HB_UNZIPFILE
Colega segue abaixo rotina q uso....
[]´s
Código: Selecionar todos
*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
Procedure FazBackupBase(lPegaPathConfig)
* Rotina para bkp base
*+±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±
LOCAL cTela := savescreen(s_geral)
//-- Variaveis necessarias para compactacao
LOCAL cNomeArquivoZip
LOCAL aArquivos:= {}
LOCAL aConteudoDir
LOCAL cCaminhoArqs :=""
LOCAL cPraQualPasta := 'BKP\'
LOCAL nOpcao := 0
#include "Directry.ch" //-- Necessario para pegar os atributos via Alias do vetor directory
AbreParam()
nOpcao := 1 // DBFs
IF nOpcao == 0
ALERT('ESC Pressionado!!! Rotina Cancelada!!!')
restscreen(s_geral, cTela)
RETURN
ENDIF
cNomeArquivoZip := strtran(alltrim(nomfil)," ","") + "_" + strtran(strtran(dtoc(date()),".",""),"/","") + ".zip"
* Pega Arquivos do tipo escolhido acima do CAminho mas a Matriz possui Nome, Tamanho, Data, Hora etc
aConteudoA := Directory( "*.dbf" )
aConteudoB := Directory( "*.exe" )
* Varre a Matriz e adiciona em outra Matriz Vazia somente os nomes dos arquivos e o caminho
AEval( aConteudoA, {|a| AADD( aArquivos, CurdirSys() + a[F_NAME]) } )
AEval( aConteudoB, {|a| AADD( aArquivos, CurdirSys() + a[F_NAME]) } )
//-- Compacta
BackZip(cNomeArquivoZip, , aArquivos)
* Se j foi feito backup no dia apaga o mais velho antes.
IF FILE( CPRAQUALPASTA + cNomeArquivoZIP )
FERASE( CPRAQUALPASTA + cNomeArquivoZIP )
ENDIF
FILEMOVE(CNOMEARQUIVOZIP, CPRAQUALPASTA + cNomeArquivoZIP)
RestScreen(s_geral, cTela)
Return
********************************************************************************
Function BackZip( cZip, cSenhaZip, aFiles, lMostraGauge )
*-- Faz Backup Compactado, com senha se for o caso
********************************************************************************
LOCAL a, b, c
lMostraGauge := IF(lMostraGauge == NIL, .T., lMostraGauge)
SET DATE TO ANSI
SET CENTURY ON
nLen := Len( aFiles )
IF lMostraGauge
aGauge := GaugeNew( 20, 15, 22, 50, "W/B", "W+/B", chr(219) )
GaugeDisplay( aGauge )
ENDIF
hb_ZipFile( cZip, aFiles, 9,IIF(lMostraGauge,;
{| cFile, nPos | GaugeUpdate( aGauge, nPos / nLen )}, NIL) ,, cSenhaZip )
/*
hb_ZipFile( cFileName,;
acFiles,;
nLevel,;
bUpdate,;
lOverwrite,;
cPassword,;
lWithPath,;
lWithDrive,;
bProgress,;
lFullPath,;
acExclude )
*/
SET DATE BRITISH
RETURN
********************************************************************************
Function Unzip( cZip, cSenhaZip, lMostra)
*-- Faz UnZIP
********************************************************************************
LOCAL aExtract
lMostra := IIF( lMostra == NIL, .T., lMostra)
aExtract := hb_GetFilesInZip( cZip ) // extract all files in zip
IF hb_UnzipFile( cZip, {| cFile | IIF( lMostra, QOut(cFile), ) },,cSenhaZip, ".\", aExtract )
IF lMostra
QOut( "File was successfully extracted" )
ENDIF
ENDIF
RETURNSun Tzu há mais de três mil anos cita nas epígrafes de seu livro “A Arte da Guerra“:
“Concentre-se nos pontos fortes, reconheça as fraquezas, agarre as oportunidades e proteja-se contra as ameaças”.
“Se não é vantajoso, nunca envie suas tropas; se não lhe rende ganhos, nunca utilize seus homens; se não é uma situação perigosa, nunca lute uma batalha precipitada”.
Até 2017 Desktop Console [ Legado ] Harbour | MinGW | DBF | CDX | FastReport | MySQL
Novos Projetos:
Desktop Visual Windev Desktop
Celular Android/iOS Windev Mobile
WEB Windev Web
Sejamos gratos a Deus.
“Concentre-se nos pontos fortes, reconheça as fraquezas, agarre as oportunidades e proteja-se contra as ameaças”.
“Se não é vantajoso, nunca envie suas tropas; se não lhe rende ganhos, nunca utilize seus homens; se não é uma situação perigosa, nunca lute uma batalha precipitada”.
Até 2017 Desktop Console [ Legado ] Harbour | MinGW | DBF | CDX | FastReport | MySQL
Novos Projetos:
Desktop Visual Windev Desktop
Celular Android/iOS Windev Mobile
WEB Windev Web
Sejamos gratos a Deus.
-
carlos_dornelas
- Usuário Nível 3

- Mensagens: 400
- Registrado em: 25 Ago 2004 21:54
-
Softwhouse
- Usuário Nível 3

- Mensagens: 324
- Registrado em: 07 Dez 2011 18:44
- Localização: Porto Alegre/RS
HB_ZIPFILE e HB_UNZIPFILE
Alguém sabe em que lib encontro as funções Curdirsys(), Gaugenew(),Gaugedisplay() e GaugeUpdate() ? Ou teria um exemplo de como compactar e descompactar pastas com subpastas ? Grato.
Fernando
HB_ZIPFILE e HB_UNZIPFILE
Código: Selecionar todos
**********************************************************************************************************
function CurdirSys() // Retorna do Diret¢rio Corrente
return HB_CurDrive()+':\'+CURDIR() + '\' //"\"+ CurDir() + "\"
**********************************************************************************************************
/***
* GaugeNew( <nRowTop>, <nColumnTop>, <nRowBottom>, <nColumnBottom>,
* [<cBackgroundColor>],
* [<cGaugeColor>],
* [<cGaugeCharacter>] ) --> aGauge
*
* Create a new gauge array
*
*/
FUNCTION GaugeNew( nTop, nLeft, nBottom, nRight, ;
cBackColor, cBarColor, cBarCharacter )
LOCAL aHandle[ B_LEN ] // Contains info about the gauge
// Assign default values
aHandle[ B_TOP ] := nTop
aHandle[ B_LEFT ] := nLeft
aHandle[ B_BOTTOM ] := nBottom
aHandle[ B_RIGHT ] := nRight
aHandle[ B_BACKCOLOR ] := "W/N"
aHandle[ B_BARCOLOR ] := "W+/N"
aHandle[ B_DISPLAYNUM ] := .T.
aHandle[ B_BARCHAR ] := CHR( 219 )
aHandle[ B_PERCENT ] := 0
// Resolve parameters
IF cBackColor <> NIL
aHandle[ B_BACKCOLOR ] := cBackColor
endif
IF cBarColor <> NIL
aHandle[ B_BARCOLOR ] := cBarColor
endif
IF cBarCharacter <> NIL
aHandle[ B_BARCHAR ] := cBarCharacter
endif
// OK, the defaults are set, now let's make sure it will fit on the
// screen correctly
IF aHandle[ B_RIGHT ] < aHandle[ B_LEFT ] + 4
aHandle[ B_RIGHT ] := aHandle[ B_LEFT ] + 4
endif
IF aHandle[ B_BOTTOM ] < aHandle[ B_TOP ] + 2
aHandle[ B_BOTTOM ] := aHandle[ B_TOP ] + 2
endif
// Determine if we can fit the bracketed number on top of the graph
IF aHandle[ B_RIGHT ] < aHandle[ B_LEFT ] + 9
aHandle[ B_DISPLAYNUM ] := .F.
endif
return( aHandle )
/***
*
* GaugeDisplay( aGauge ) --> aGauge
*
* Display a gauge array to the screen
*
*/
FUNCTION GaugeDisplay( aHandle )
LOCAL nCenter := ROUND( (aHandle[B_RIGHT] - aHandle[B_LEFT]) / 2, 0) + 1
LOCAL cOldColor := SETCOLOR( aHandle[ B_BACKCOLOR ] )
@ aHandle[ B_TOP ], aHandle[ B_LEFT ] CLEAR TO ;
aHandle[ B_BOTTOM ], aHandle[ B_RIGHT ]
@ aHandle[ B_TOP ], aHandle[ B_LEFT ], ;
aHandle[ B_BOTTOM ], aHandle[ B_RIGHT ] BOX B_BOXLINES
IF aHandle[ B_DISPLAYNUM ]
@ aHandle[ B_TOP ], nCenter SAY "[ ]"
endif
SETCOLOR( cOldColor )
// Draw bar to show current percent
GaugeUpdate( aHandle, aHandle[ B_PERCENT ] )
return( aHandle )
/***
*
* GaugeUpdate( aGauge, nPercent ) --> aGauge
*
* Updates a gauge with a new progress value and redisplays the gauge
* to the screen to the screen
*
*/
FUNCTION GaugeUpdate( aHandle, nPercent )
LOCAL nCenter := ROUND( (aHandle[B_RIGHT] - aHandle[B_LEFT]) / 2, 0) + 1
LOCAL cOldColor := SETCOLOR( aHandle[ B_BARCOLOR ] )
LOCAL nBarRatio := (aHandle[ B_RIGHT ]) - (aHandle[ B_LEFT ] + 1)
LOCAL nRow := 0
LOCAL nCols := 0
IF aHandle[ B_DISPLAYNUM ]
@ aHandle[ B_TOP ], nCenter + 2 SAY STR( nPercent * 100, 3 ) + "%"
endif
IF nPercent > 1
nPercent := 1
endif
IF nPercent < 0
nPercent := 0
endif
nCols := ROUND( nPercent * nBarRatio, 0 )
@ aHandle[ B_TOP ] + 1, aHandle[ B_LEFT ] + 1 CLEAR TO ;
aHandle[ B_BOTTOM ] - 1, aHandle[ B_RIGHT ] - 1
FOR nRow := 1 TO (aHandle[ B_BOTTOM ] - aHandle[ B_TOP ] - 1)
@ nRow + aHandle[ B_TOP ], aHandle[ B_LEFT ] + 1 SAY ;
REPLICATE( aHandle[ B_BARCHAR ], nCols )
NEXT
SETCOLOR( cOldColor )
return( aHandle )
Sun Tzu há mais de três mil anos cita nas epígrafes de seu livro “A Arte da Guerra“:
“Concentre-se nos pontos fortes, reconheça as fraquezas, agarre as oportunidades e proteja-se contra as ameaças”.
“Se não é vantajoso, nunca envie suas tropas; se não lhe rende ganhos, nunca utilize seus homens; se não é uma situação perigosa, nunca lute uma batalha precipitada”.
Até 2017 Desktop Console [ Legado ] Harbour | MinGW | DBF | CDX | FastReport | MySQL
Novos Projetos:
Desktop Visual Windev Desktop
Celular Android/iOS Windev Mobile
WEB Windev Web
Sejamos gratos a Deus.
“Concentre-se nos pontos fortes, reconheça as fraquezas, agarre as oportunidades e proteja-se contra as ameaças”.
“Se não é vantajoso, nunca envie suas tropas; se não lhe rende ganhos, nunca utilize seus homens; se não é uma situação perigosa, nunca lute uma batalha precipitada”.
Até 2017 Desktop Console [ Legado ] Harbour | MinGW | DBF | CDX | FastReport | MySQL
Novos Projetos:
Desktop Visual Windev Desktop
Celular Android/iOS Windev Mobile
WEB Windev Web
Sejamos gratos a Deus.
-
Softwhouse
- Usuário Nível 3

- Mensagens: 324
- Registrado em: 07 Dez 2011 18:44
- Localização: Porto Alegre/RS
- Jairo Maia
- Moderador
- Mensagens: 2785
- Registrado em: 16 Ago 2010 13:46
- Localização: Campinas-SP
HB_ZIPFILE e HB_UNZIPFILE
Olá pessoal,
Alguém sabe me dizer qual arquivo .CH devo incluir para testar a função Gauge() postada acima pelo Fladimir?
Incluir a diretiva hbziparc.hbc não é, já tenho essa diretiva em meu arquivo .Hbp. Já gero arquivos .ZIP, mas queria ver se substituo minha função que só mostra o nome de qual arquivo está sendo zipado por um Gauge()
Alguém sabe me dizer qual arquivo .CH devo incluir para testar a função Gauge() postada acima pelo Fladimir?
Incluir a diretiva hbziparc.hbc não é, já tenho essa diretiva em meu arquivo .Hbp. Já gero arquivos .ZIP, mas queria ver se substituo minha função que só mostra o nome de qual arquivo está sendo zipado por um Gauge()
Abraços, Jairo
Harbour / Clipper 5.2e - Blinker 7
(Não respondo dúvidas por MP ou E-mail. Por favor, não encaminhe via mensagem privada ou e-mail, dúvidas que podem ser compartilhadas com todos no fórum)
Harbour / Clipper 5.2e - Blinker 7
(Não respondo dúvidas por MP ou E-mail. Por favor, não encaminhe via mensagem privada ou e-mail, dúvidas que podem ser compartilhadas com todos no fórum)
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
HB_ZIPFILE e HB_UNZIPFILE
Caso não encontre outra opção, uma possibilidade é acrescentar um arquivo de cada vez.
Código: Selecionar todos
acFileList := Directory( "*.sql" )
GrafTempo( "*.sql" )
FOR EACH oElement IN acFileList
hb_ZipFile( cZipName, oElement[ F_NAME ],,,, zip_pwd )
GrafTempo( oElement:__EnumIndex, Len( acFileList ) )
fErase( oElement[ F_NAME ] )
NEXT
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
-
Kapiaba
- Colaborador

- Mensagens: 1908
- Registrado em: 07 Dez 2012 16:14
- Localização: São Paulo
- Contato:
HB_ZIPFILE e HB_UNZIPFILE
PBACKUP COMPLETO EM FIVEWIN
abs.
Regards, saludos.
abs.
Regards, saludos.
- Anexos
-
PBACKUP.rar- PBACKUP COMPLETO EM FIVEWIN
- (2.34 MiB) Baixado 62 vezes
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
HB_ZIPFILE e HB_UNZIPFILE
Resumindo: mesma coisa de outro jeito.
Mas gostei muito do comentário do fonte, mostra o que precisa, mas que não é usado.
Mas gostei muito do comentário do fonte, mostra o que precisa, mas que não é usado.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
-
alxsts
- Colaborador

- Mensagens: 3092
- Registrado em: 12 Ago 2008 15:50
- Localização: São Paulo-SP-Brasil
HB_ZIPFILE e HB_UNZIPFILE
Olá!
Programa de demonstração:
Rotinas utilizadas:
Este código foi originalmente fornecido no lançamento do Clipper 5. Está na pasta Clipper\Source\Sample de uma instalação típica daquele compilador. Seguem os fontes extraídos do original:Jairo Maia escreveu:Alguém sabe me dizer qual arquivo .CH devo incluir para testar a função Gauge() postada acima pelo Fladimir?
Programa de demonstração:
Código: Selecionar todos
/***
*
* GaugDemo.prg
*
* Sample program to demonstrate the use of a bar progress gauge
*
* Copyright (c) 1993-1995, Computer Associates International Inc.
* All rights reserved.
*
*/
#include "Inkey.ch"
PROCEDURE GaugDemo
LOCAL i
LOCAL hGauge
LOCAL nPercent
CLS
SET CURSOR OFF
hGauge := GaugeNew( 5, 5, 7, MAXCOL() - 5, "W/B", "W+/B" )
GaugeDisplay( hGauge )
SETCOLOR( "W+/N" )
@ 1,0 SAY PADC( "Gauge Demo", MAXCOL() )
SETCOLOR( "W/N" )
@ 3,0 SAY PADC( "Use , , PgUp and PgDn to change gauge, Esc to exit", MAXCOL() )
nPercent := 0
i := 0
DO WHILE i <> K_ESC
i := INKEY(0)
DO CASE
CASE i == K_UP
nPercent += .01
CASE i == K_DOWN
nPercent -= .01
CASE i == K_PGUP
nPercent += .1
CASE i == K_PGDN
nPercent -= .1
ENDCASE
// Ensure that nPercent is within bounds
IF nPercent < 0
TONE(300, 1)
nPercent := 0
ENDIF
IF nPercent > 1
TONE(300, 1)
nPercent := 1
ENDIF
GaugeUpdate( hGauge, nPercent )
ENDDO
SET CURSOR ON
SETPOS( MAXROW(), 0 )
RETURN
Código: Selecionar todos
/***
*
* Gauge.prg
*
* Sample functions to create, display, and update a percentage completed
* progress gauge. This function can be used for creating user interface
* options such as a status bar to indicate the current status of a process.
*
* Copyright (c) 1993-1995, Computer Associates International Inc.
* All rights reserved.
*
* Note: Compile with /W /N options
*
*/
// Box array definitions
#define B_LEN 9
#define B_TOP 1
#define B_LEFT 2
#define B_BOTTOM 3
#define B_RIGHT 4
#define B_BACKCOLOR 5
#define B_BARCOLOR 6
#define B_DISPLAYNUM 7
#define B_BARCHAR 8
#define B_PERCENT 9
#define B_BOXLINES "ÚÄ¿³ÙÄÀ³"
/***
* GaugeNew( <nRowTop>, <nColumnTop>, <nRowBottom>, <nColumnBottom>,
* [<cBackgroundColor>],
* [<cGaugeColor>],
* [<cGaugeCharacter>] ) --> aGauge
*
* Create a new gauge array
*
*/
FUNCTION GaugeNew( nTop, nLeft, nBottom, nRight, ;
cBackColor, cBarColor, cBarCharacter )
LOCAL aHandle[ B_LEN ] // Contains info about the gauge
// Assign default values
aHandle[ B_TOP ] := nTop
aHandle[ B_LEFT ] := nLeft
aHandle[ B_BOTTOM ] := nBottom
aHandle[ B_RIGHT ] := nRight
aHandle[ B_BACKCOLOR ] := "W/N"
aHandle[ B_BARCOLOR ] := "W+/N"
aHandle[ B_DISPLAYNUM ] := .T.
aHandle[ B_BARCHAR ] := CHR( 219 )
aHandle[ B_PERCENT ] := 0
// Resolve parameters
IF cBackColor <> NIL
aHandle[ B_BACKCOLOR ] := cBackColor
ENDIF
IF cBarColor <> NIL
aHandle[ B_BARCOLOR ] := cBarColor
ENDIF
IF cBarCharacter <> NIL
aHandle[ B_BARCHAR ] := cBarCharacter
ENDIF
// OK, the defaults are set, now let's make sure it will fit on the
// screen correctly
IF aHandle[ B_RIGHT ] < aHandle[ B_LEFT ] + 4
aHandle[ B_RIGHT ] := aHandle[ B_LEFT ] + 4
ENDIF
IF aHandle[ B_BOTTOM ] < aHandle[ B_TOP ] + 2
aHandle[ B_BOTTOM ] := aHandle[ B_TOP ] + 2
ENDIF
// Determine if we can fit the bracketed number on top of the graph
IF aHandle[ B_RIGHT ] < aHandle[ B_LEFT ] + 9
aHandle[ B_DISPLAYNUM ] := .F.
ENDIF
RETURN( aHandle )
/***
*
* GaugeDisplay( aGauge ) --> aGauge
*
* Display a gauge array to the screen
*
*/
FUNCTION GaugeDisplay( aHandle )
LOCAL nCenter := ROUND( (aHandle[B_RIGHT] - aHandle[B_LEFT]) / 2, 0) + 1
LOCAL cOldColor := SETCOLOR( aHandle[ B_BACKCOLOR ] )
@ aHandle[ B_TOP ], aHandle[ B_LEFT ] CLEAR TO ;
aHandle[ B_BOTTOM ], aHandle[ B_RIGHT ]
@ aHandle[ B_TOP ], aHandle[ B_LEFT ], ;
aHandle[ B_BOTTOM ], aHandle[ B_RIGHT ] BOX B_BOXLINES
IF aHandle[ B_DISPLAYNUM ]
@ aHandle[ B_TOP ], nCenter SAY "[ ]"
ENDIF
SETCOLOR( cOldColor )
// Draw bar to show current percent
GaugeUpdate( aHandle, aHandle[ B_PERCENT ] )
RETURN( aHandle )
/***
*
* GaugeUpdate( aGauge, nPercent ) --> aGauge
*
* Updates a gauge with a new progress value and redisplays the gauge
* to the screen to the screen
*
*/
FUNCTION GaugeUpdate( aHandle, nPercent )
LOCAL nCenter := ROUND( (aHandle[B_RIGHT] - aHandle[B_LEFT]) / 2, 0) + 1
LOCAL cOldColor := SETCOLOR( aHandle[ B_BARCOLOR ] )
LOCAL nBarRatio := (aHandle[ B_RIGHT ]) - (aHandle[ B_LEFT ] + 1)
LOCAL nRow := 0
LOCAL nCols := 0
IF aHandle[ B_DISPLAYNUM ]
@ aHandle[ B_TOP ], nCenter + 2 SAY STR( nPercent * 100, 3 ) + "%"
ENDIF
IF nPercent > 1
nPercent := 1
ENDIF
IF nPercent < 0
nPercent := 0
ENDIF
nCols := ROUND( nPercent * nBarRatio, 0 )
@ aHandle[ B_TOP ] + 1, aHandle[ B_LEFT ] + 1 CLEAR TO ;
aHandle[ B_BOTTOM ] - 1, aHandle[ B_RIGHT ] - 1
FOR nRow := 1 TO (aHandle[ B_BOTTOM ] - aHandle[ B_TOP ] - 1)
@ nRow + aHandle[ B_TOP ], aHandle[ B_LEFT ] + 1 SAY ;
REPLICATE( aHandle[ B_BARCHAR ], nCols )
NEXT
SETCOLOR( cOldColor )
RETURN( aHandle )
[]´s
Alexandre Santos (AlxSts)
Alexandre Santos (AlxSts)
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
HB_ZIPFILE e HB_UNZIPFILE
Acho que me confundi sobre o que o Jairo quer.
É sobre como usar dentro da rotina de ZIP, ou é um gráfico mesmo ?
É sobre como usar dentro da rotina de ZIP, ou é um gráfico mesmo ?
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
HB_ZIPFILE e HB_UNZIPFILE
Uia, quase deu certo, falhou o mais simples kkkk
gráfico 1: baseado em quantidade de arquvos, com previsão de tempo (arquivo 1, 2, 3, 4....)
gráfico 2: baseado no tamanho/posição do zip atual, com previsão de tempo (um arquivo sendo zipado)
gráfico 3: baseado no tamanho/posição de todos os zips, com previsão de tempo (total zipando tudo)
gráfico 1: baseado em quantidade de arquvos, com previsão de tempo (arquivo 1, 2, 3, 4....)
gráfico 2: baseado no tamanho/posição do zip atual, com previsão de tempo (um arquivo sendo zipado)
gráfico 3: baseado no tamanho/posição de todos os zips, com previsão de tempo (total zipando tudo)
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
HB_ZIPFILE e HB_UNZIPFILE
Vou fazer do meu jeito que já mostrei, mas a tentativa pelo harbour foi assim:
Não sei porque, o primeiro codeblock não está recebendo o que deveria receber, e atrapalha tudo.
a e b deveriam ser atual e total, funcionou antes, mas agora deixou de funcionar.
Código: Selecionar todos
PROCEDURE Main
LOCAL cFile, aList := {}, aFiles, bUm, bOutro, nTotal := 0, nAcumulado := 0
aFiles := Directory( "*.*" )
AEval( aFiles, { | e | AAdd( aList, e[ F_NAME ] ), nTotal += e[ F_SIZE ] } )
cFile := "copia_" + Dtos( Date() ) + SoNumeros( Time() ) + ".zip"
bUm := { | a, b | Mostraum(a,b,@aFiles,@nAcumulado) }
bOutro := { | a, b | MostraOutro(a,b,nAcumulado,nTotal ) }
SetMode(33,100)
SetColor( "W/B" )
CLS
GrafTempo( "total" )
GrafTempo2( "atual" )
GrafTempo3( "arquivo" )
Hb_ZIPFILE( cFile ,; // Carpeta destino de la copia de seguridad
aList ,; // Fichero o array a realizar el backup
Nil ,; // Prioridad maxima 9
bUm ,; // CodeBlog para refrescar oMeter y sistema
.T. ,; // Sobreescribir el fichero
Nil ,; // Password para encritar
Nil ,; // Guardar el path
Nil ,; // Guardar la unidad
bOutro ) // CodeBlock para progreso de archivos
Inkey(0)
RETURN
FUNCTION MostraUm( a, b, aFiles, nAcumulado )
IF ValType( a ) == "N"
nAcumulado += aFiles[a,F_SIZE]
GrafTempo3( a, b )
ENDIF
RETURN Nil
FUNCTION MostraOutro( a, b, nAcumulado, nTotal )
GrafTempo2( a, b )
GrafTempo( a + nAcumulado, nTotal )
RETURN Nil
a e b deveriam ser atual e total, funcionou antes, mas agora deixou de funcionar.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
HB_ZIPFILE e HB_UNZIPFILE
A rotina de sempre, a mesma dos últimos 10 anos ou mais.
Só tive que modificar pra poder mostrar 3 ao mesmo tempo, mas esta é a original
forma de uso, exemplo:
Vai precisar criar as funções que retornam cor, e é fixo nas duas últimas linhas.
Além do gráfico, mostra os números, quanto tempo já foi, e quanto tempo falta.
Pra o teste e vídeo, criei 3 diferentes alterando a posição.
A função do harbour hb_ZipFile aceita DOIS CODEBLOCKS.
No primeiro codeblock é referente a arquivos, exemplo 10 arquivos, vai passar 1,10 depois 2,10, até 10,10
No segundo codeblock é referente a zip atual, vai passar byte atual, byte total
O primeiro gráfico fiz baseado nos parâmetros do primeiro codeblock.
O segundo gráfico fiz baseado nos parâmetros do segundo codeblock.
E o terceiro gráfico, fiz igual faço na reindexação, somo o total, e a cada arquivo processado vou somando o tamanho.
O gráfico é atualizado somente 1 vez por segundo, pra não atrapalhar processamento, então é normal terminar o processo e o gráfico não ter chegado a 100%, mas isso não importa, porque acabou, e o gráfico não interessa mais.
Como é console.....
Caso use durante impressão, sem problemas, porque muda pra SCREEN e depois volta para onde estava.
Dá pra usar a progressbar do Windows ?
Sim, mas prefiro assim, senão teria que remover toda a grade da barra de progresso.
Só tive que modificar pra poder mostrar 3 ao mesmo tempo, mas esta é a original
Código: Selecionar todos
/*
ZE_GRAFTEMPO - GRAFICOS DE PROCESSAMENTO
1990.05 - José Quintas
*/
#include "inkey.ch"
#include "set.ch"
#define GRAFMODE 1
#define GRAFTIME 2
#define GRAF_SEC_OLD 1
#define GRAF_SEC_INI 2
#define GRAF_TXT_BAR 3
#define GRAF_TXT_TEXT 4
FUNCTION GrafProc( nRow, nCol )
THREAD STATIC GrafInfo := { 1, "X" }
LOCAL mSetDevice
hb_Default( @nRow, MaxRow() - 1 )
hb_Default( @nCol, MaxCol() - 2 )
IF GrafInfo[ GRAFTIME ] != Time()
mSetDevice := Set( _SET_DEVICE, "SCREEN" )
@ nRow, nCol SAY "(" + Substr( "|/-\", GrafInfo[ GRAFMODE ], 1 ) + ")" COLOR SetColorMensagem()
GrafInfo[ GRAFMODE ] = iif( GrafInfo[ GRAFMODE ] == 4, 1, GrafInfo[ GRAFMODE ] + 1 )
Set( _SET_DEVICE, mSetDevice )
GrafInfo[ GRAFTIME ] := Time()
ENDIF
RETURN .T.
FUNCTION GrafTempo( xContNow, xContTotal )
THREAD STATIC aStatic := { 0, 0, "", "" }
LOCAL nSecondsNow, nSecondsRemaining, nSecondsElapsed, nCont, nPos, cTxt, cCorAnt
LOCAL nPercent, cTexto, mSetDevice
xContNow := iif( xContNow == NIL, "", xContNow )
IF Empty( aStatic[ GRAF_TXT_BAR ] )
aStatic[ GRAF_TXT_BAR ] := Replicate( ".", MaxCol() )
FOR nCont = 1 to 10
nPos := Int( Len( aStatic[ GRAF_TXT_BAR ] ) / 10 * nCont )
cTxt := lTrim( Str( nCont, 3 ) ) + "0%" + Chr(30)
aStatic[ GRAF_TXT_BAR ] := Stuff( aStatic[ GRAF_TXT_BAR ], ( nPos - Len( cTxt ) ) + 1, Len( cTxt ), cTxt )
NEXT
aStatic[ GRAF_TXT_BAR ] := Chr(30) + aStatic[ GRAF_TXT_BAR ]
ENDIF
mSetDevice := Set( _SET_DEVICE, "SCREEN" )
DO CASE
CASE ValType( xContNow ) == "C"
cTexto := xContNow
aStatic[ GRAF_SEC_INI ] := Int( Seconds() )
CASE xContTotal == NIL
nPercent := xContNow
CASE xContNow >= xContTotal
nPercent := 100
CASE xContTotal == 0
nPercent := 0
OTHERWISE
nPercent := xContNow / xContTotal * 100
ENDCASE
xContNow := iif( ValType( xContNow ) != "N", 0, xContNow )
xContTotal := iif( ValType( xContTotal ) != "N", 0, xContTotal )
cCorAnt := SetColor()
SetColor( SetColorMensagem() )
nSecondsNow := Int( Seconds() )
IF nPercent == NIL
aStatic[ GRAF_SEC_OLD ] := nSecondsNow
Mensagem()
@ MaxRow(), 0 SAY aStatic[ GRAF_TXT_BAR ]
aStatic[ GRAF_TXT_TEXT ] := cTexto
ELSEIF nPercent == 100 .OR. ( nSecondsNow != aStatic[ GRAF_SEC_OLD ] .AND. nPercent != 0 )
aStatic[ GRAF_SEC_OLD ] := nSecondsNow
nSecondsElapsed := nSecondsNow - aStatic[ GRAF_SEC_INI ]
DO WHILE nSecondsElapsed < 0
nSecondsElapsed += ( 24 * 3600 ) // Acima de 24 horas
ENDDO
nSecondsRemaining := nSecondsElapsed / nPercent * ( 100 - nPercent )
@ MaxRow()-1, 0 SAY aStatic[ GRAF_TXT_TEXT ] + " " + Ltrim( Transform( xContNow, PicVal(14,0) ) ) + "/" + Ltrim( Transform( xContTotal, PicVal(14,0) ) )
cTxt := "Gasto:"
cTxt += " " + Ltrim( Str( Int( nSecondsElapsed / 3600 ), 10 ) ) + "h"
cTxt += " " + Ltrim( Str( Mod( Int( nSecondsElapsed / 60 ), 60 ), 10, 0 ) ) + "m"
cTxt += " " + Ltrim( Str( Mod( nSecondsElapsed, 60 ), 10, 0 ) ) + "s"
cTxt += Space(3)
cTxt += "Falta:"
cTxt += " " + Ltrim( Str( Int( nSecondsRemaining / 3600 ), 10 ) ) + "h"
cTxt += " " + Ltrim( Str( Mod( Int( nSecondsRemaining / 60 ), 60 ), 10, 0 ) ) + "m"
cTxt += " " + Ltrim( Str( Mod( nSecondsRemaining, 60 ), 10, 0 ) ) + "s"
@ Row(), Col() SAY Padl( cTxt, MaxCol() - Col() - 4 )
GrafProc()
@ MaxRow(), 0 SAY Left( aStatic[ GRAF_TXT_BAR ], Len( aStatic[ GRAF_TXT_BAR ] ) * nPercent / 100 ) COLOR SetColorFocus()
ENDIF
SetColor( cCorAnt )
SET( _SET_DEVICE, mSetDevice )
RETURN .T.
Código: Selecionar todos
USE ARQUIVO
GrafTempo( "processando" )
DO WHILE ! Eof()
GrafTempo( RecNo(), LastRec() )
SKIP
ENDDO
Além do gráfico, mostra os números, quanto tempo já foi, e quanto tempo falta.
Pra o teste e vídeo, criei 3 diferentes alterando a posição.
A função do harbour hb_ZipFile aceita DOIS CODEBLOCKS.
No primeiro codeblock é referente a arquivos, exemplo 10 arquivos, vai passar 1,10 depois 2,10, até 10,10
No segundo codeblock é referente a zip atual, vai passar byte atual, byte total
O primeiro gráfico fiz baseado nos parâmetros do primeiro codeblock.
O segundo gráfico fiz baseado nos parâmetros do segundo codeblock.
E o terceiro gráfico, fiz igual faço na reindexação, somo o total, e a cada arquivo processado vou somando o tamanho.
O gráfico é atualizado somente 1 vez por segundo, pra não atrapalhar processamento, então é normal terminar o processo e o gráfico não ter chegado a 100%, mas isso não importa, porque acabou, e o gráfico não interessa mais.
Código: Selecionar todos
FUNCTION GrafProc( nRow, nCol )
THREAD STATIC GrafInfo := { 1, "X" }
LOCAL mSetDevice
hb_Default( @nRow, MaxRow() - 1 )
hb_Default( @nCol, MaxCol() - 2 )
IF GrafInfo[ GRAFTIME ] != Time()
mSetDevice := Set( _SET_DEVICE, "SCREEN" )
Caso use durante impressão, sem problemas, porque muda pra SCREEN e depois volta para onde estava.
Dá pra usar a progressbar do Windows ?
Sim, mas prefiro assim, senão teria que remover toda a grade da barra de progresso.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/