Code: Select all | Expand
// C:\FWH..\SAMPLES\UNZIP2.PRG simples teste. kapiabafwh@gmail.com
#include "FiveWin.ch"
#Include "Directry.ch"
#Define CLR_PINK nRGB( 255, 128, 128 ) //-> Rosa. uiiii. kkkkkk
#Define CLR_NBLUE nRGB( 128, 128, 192 )
#Define CLR_MSPURPLE nRGB( 0, 120, 215 ) //-> Purpura.
#Define CLR_MSRED nRGB( 232, 17, 35 )
#Define CLR_MSGRAY nRGB( 229, 229, 229 )
#Define CLR_LGRAY nRGB( 230, 230, 230 )
FUNCTION Main()
MEMVAR cPRGPATH, cFILEPATH
cPRGPATH := cFILEPATH(GETMODULEFILENAME(GETINSTANCE()))
cPRGPATH := cShortName(cPRGPATH) //-> Modified / Modificado al final
XBACKUP()
lCHDIR(cPRGPATH)
RETURN NIL
FUNCTION XBACKUP()
LOCAL oDlg, oFont, cDest, cArqZip, aDir1, vPasta, X, nTotal
LOCAL cTipo := "1"
// LOCAL cDestino := LEFT("C:\"+CurDir()+SPACE(100),100)
LOCAL cDestino
// archivos de Origen:
// LOCAL cOrigem := LEFT("C:\"+CurDir()+"\*.PRG"+SPACE(100),100)
LOCAL cOrigem
LOCAL cSenha := SPACE(10)
LOCAL oBtn, oBtn2, oSaida, aGrad, oBrush1, oBrush2, aArq := {}
LOCAL c_ExtArq:="zip" //extensao do arquivo que sera criado
LOCAL oCursorBtn := TCursor():New(, 'HAND' )
// De onde pegar os arquivos:
cOrigem := Curdrive()+":\fwh1905\samples\*.PRG"
cDestino := Curdrive()+":\backup\" // "C:\BACKUP"
// ? cDestino // "C:\BACKUP" // donde guardar la copia
IF .NOT. lIsdir( cDestino )
LMkdir( cDestino )
ENDIF
SetBalloon( .T. )
aGrad := { { 0.30, CLR_MSGRAY, CLR_MSPURPLE },{ 0.50, CLR_MSPURPLE, CLR_MSGRAY }, .F. }
DEFINE BRUSH oBrush1 COLOR nRGB( 250, 213, 174 ) STYLE HORIZONTAL
DEFINE BRUSH oBrush2 COLOR nRGB( 192, 192, 192 ) STYLE HORIZONTAL
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -35 BOLD
DEFINE DIALOG oDlg TITLE "FIVEWIN:- BACKUP - RESTORE -" SIZE 350, 350 ;
PIXEL TRUEPIXEL RESIZABLE GRADIENT aGrad
@ 050, 75 BTNBMP oBtn OF oDlg SIZE 200, 70 NOBORDER ADJUST TRANSPARENT ;
FILE "..\bitmaps\butt1upD.bmp", "..\bitmaps\butt1do.bmp",nil, ;
"..\bitmaps\butt1upL.bmp" ;
FONT oFont COLOR CLR_PINK, CLR_BLACK PROMPT "&BACKUP" CENTER ;
ACTION ( cTipo := "BACKUP", oDlg:End() ) ;
TOOLTIP "Backup"
oBtn:bClrGrad = {| lInvert | If( ! lInvert, ;
{ { 0.25, RGB( 245, 245, 235 ), RGB( 250, 250, 245 ) }, ;
{ 0.75, RGB( 250, 250, 245 ), RGB( 245, 245, 235 ) } }, ;
{ { 0.25, RGB( 250, 250, 245 ), RGB( 245, 245, 235 ) }, ;
{ 0.75, RGB( 245, 245, 235 ), RGB( 250, 250, 245 ) } } ) }
oBtn:nClrBorder := iif( oBtn:lMOver, RGB( 219, 230, 244 ), RGB( 219, 230, 244 ) )
oBtn:oCursor := oCursorBtn
@ 150, 75 BTNBMP oBtn2 OF oDlg SIZE 200, 70 NOBORDER ADJUST TRANSPARENT ;
FILE "..\bitmaps\butt1upD.bmp", "..\bitmaps\butt1do.bmp",nil, ;
"..\bitmaps\butt1upL.bmp" ;
FONT oFont COLOR CLR_PINK, CLR_BLACK PROMPT "&RESTORE" CENTER ;
ACTION ( cTipo := "RESTORE", oDlg:End() ) ;
TOOLTIP "Restore"
oBtn2:bClrGrad = {| lInvert | If( ! lInvert, ;
{ { 0.25, RGB( 245, 245, 235 ), RGB( 250, 250, 245 ) }, ;
{ 0.75, RGB( 250, 250, 245 ), RGB( 245, 245, 235 ) } }, ;
{ { 0.25, RGB( 250, 250, 245 ), RGB( 245, 245, 235 ) }, ;
{ 0.75, RGB( 245, 245, 235 ), RGB( 250, 250, 245 ) } } ) }
oBtn2:nClrBorder := iif( oBtn2:lMOver, RGB( 219, 230, 244 ), RGB( 219, 230, 244 ) )
oBtn2:oCursor := oCursorBtn
@ 250, 75 BTNBMP oSaida OF oDlg SIZE 200, 70 NOBORDER ADJUST TRANSPARENT ;
FILE "..\bitmaps\butt1upD.bmp", "..\bitmaps\butt1do.bmp",nil, ;
"..\bitmaps\butt1upL.bmp" ;
FONT oFont COLOR CLR_PINK, CLR_BLACK PROMPT "&EXIT" CENTER ;
ACTION ( cTipo := "SAIDA", oDlg:End() ) ;
TOOLTIP "Exit/Salida"
oSaida:bClrGrad = {| lInvert | If( ! lInvert, ;
{ { 0.25, RGB( 245, 245, 235 ), RGB( 250, 250, 245 ) }, ;
{ 0.75, RGB( 250, 250, 245 ), RGB( 245, 245, 235 ) } }, ;
{ { 0.25, RGB( 250, 250, 245 ), RGB( 245, 245, 235 ) }, ;
{ 0.75, RGB( 245, 245, 235 ), RGB( 250, 250, 245 ) } } ) }
oSaida:nClrBorder := iif( oSaida:lMOver, RGB( 219, 230, 244 ), RGB( 219, 230, 244 ) )
oSaida:oCursor := oCursorBtn
oSaida:lCancel := .T.
ACTIVATE DIALOG oDlg CENTERED
IF cTipo != "SAIDA"
? "Tipo: ", cTipo, cDestino, cOrigem
ENDIF
IF cTipo = "RESTORE"
cOrigem := Curdrive()+":\backup\BACKUP.ZIP"
ENDIF
IF .NOT. FILE( AllTrim( cOrigem ) )
Alert( "Arquivo: " + AllTrim( cOrigem ) + "; Nao encontrado(bakcup.zip)!" )
RETURN NIL
ENDIF
IF Right( AllTrim( cDestino ), 1 ) != "\"
cDest := AllTrim( cDestino ) + "\NUL"
cArqZip := AllTrim( cDestino ) + "\backup." + c_ExtArq
ELSE
cDest := AllTrim( cDestino ) + "NUL"
cArqZip := AllTrim( cDestino ) + "backup." + c_ExtArq
ENDIF
IF .NOT. FILE( cDest )
Alert( "O Drive: " + AllTrim( cDestino ) + "; Nao encontrado!" )
RETURN NIL
ENDIF
IF cTipo = "BACKUP" // BACKUP
aArq := {}
IF "*" $ cOrigem
aDir1 := Directory( AllTrim( cOrigem ) )
vPasta := LEFT( cOrigem, RAt( "\", cOrigem ) )
FOR x = 1 TO Len( aDir1 )
AAdd( aArq, vPasta + aDir1[ x, 1 ] )
NEXT
ELSE
AAdd( aArq, AllTrim( cOrigem ) )
ENDIF
nTotal := Len( aArq )
hb_zipfile( cArqZip, aArq, 9, {| cFile, nPos | eProgresso( cFile, nPos, nTotal ) }, .T., , , .F., .F., )
? "Backup Listo"
ELSE // RESTORE
cDest := AllTrim( cDestino )
IF Right( AllTrim( cDestino ), 1 ) != "\"
cDest += "\"
ENDIF
aArq := hb_GetFilesInZip( AllTrim( cOrigem ) )
nTotal := Len( aArq )
hb_UnzipFile( AllTrim( cOrigem ), {| cFile, nPos | eProgresso( cFile, nPos, nTotal ) },,, cDest, aArq )
? "Restore Listo"
ENDIF
RETURN NIL
FUNCTION eProgresso(vtxt,xPerc,wTot)
Local nPre:=(xPerc*100)/wTot, nBar:=(nPre*74)/100
// Completar aqui depois...
RETURN NIL
/*
* SPN.PRG
*
* cShortName() - FilePath Long to Short (GetShortPathNameA())
*
* Soporte a Funciones del Api de Windows
*
* Andrade A. Daniel - 2002
* Rosario, Argentina
*
* Libre Distribución
*/
/*
* cShortName()
*/
FUNCTION cShortName( cLong )
Local cShort := Space(164) + Chr(0)
Local nBuffer := 164
Local nLen
nLen := GetSPName( cLong, @cShort, nBuffer )
cShort := Left( cShort, nLen )
RETURN( cShort )
// Windows Api
DLL32 STATIC FUNCTION GetSPName( lpszLongPath AS STRING, lpszShortPath AS STRING, lBuffer AS LONG ) ;
AS LONG PASCAL FROM "GetShortPathNameA" LIB "kernel32"
// FIN / END
Regards, saludos.