RE:AQUI DEJO RUTINA PARA RELIZAR UN RESPALDO BACKU
Aqui les dejo otra rutina para respaldar...
Param drv_dat, drv_resp, DirAct
public wArc,wDest, wint, xdisco
Dime wDirec(1,1)
Dime xUnidf(1,1)
***************************************************
*** Rutina de Respaldo en Disquettes ***
***************************************************
set talk off
do While .t.
nFil=ADir(wDirec,'&drv_dat'+'*.*')
=asort(wDirec,1)
wcapdisk=0
xUnd=Substr(drv_resp,1,2)
wInt=0
Define Windows Respaldo from 13,30 to 24,80 title 'Respaldo' system ;
Icon File c:copawinmpicosideas.ico noMinimize Close noFloat noGrow noZoom
activate window Respaldo
Show Window Respaldo
vr=.t.
Op=MessageBox('Inserte el Disco',1+64+0,'Verifica Disco')
If Op = 2
vr=.t.
Exit
Endif
If verUndRes() = 0
vr=.t.
Exit
Endif
xcapdsk=wcapdisk
calcDsk()
xdisco=1
ban_dsk=0
Opcion=0
For PosLis = 1 to nFil
If ban_dsk = 0
If GenID() = 0
Exit
Endif
ban_dsk=1
Endif
wArc='&drv_dat'+wDirec(poslis,1)
wDest='&drv_resp'+wDirec(poslis,1)
wcapdisk=diskSpace('&xUnd')
IF wCapDisk < 100
xDisco=xdisco+1
op=MessageBox('Inserte el Disco Numero '+Str(xDisco,2),0+64+0,'Atencion')
If verUndRes() = 0
Wait Windows 'Respaldo Inconcluso <CANCELADO>'
vr=.t.
Exit
Endif
ban_dsk=0
Endif
@ 2,2 say Space(76)
@ 3,2 say Space(76)
@ 2,2 say 'Copiando:'+wArc
@ 3,2 say 'hacia :'+wDest
xExt=Upper(Right(wArc,3))
If File(wDest)
If Opcion = 0 .or. Opcion <> 3
do form forma_Botones with wDest to opcion
Endif
If Opcion = 4
Exit
Endif
If Opcion = 3 .or. Opcion = 1
DelFile(wDest)
Endif
If Opcion = 2
xExt='ZZZ'
Endif
Endif
If xExt <> 'DBF' .And. xExt <> 'DCT' .and. xExt <> 'DBF' .and. xExt <> 'DCX' .and. xExt <> 'DBC' .and. xExt <> 'CDX' .and. xExt <> 'FPT' .and. xExt <> 'TBK'
@ 4,11 say 'Archivo I G N O R A D O'
Inkey(.5)
@ 4,11 say Space(50)
Else
&& Archivo origen &&
FilOpen=fOpen('&wArc')
If FilOpen = -1
=MessageBox('El Archivo Origen no Puede Abrirse...Proceso Terminado',0+64+0,'Error')
vr=.f.
exit
Endif
LenFop=fSeek(Filopen,0,2) && tamaño de archivo &&
=fSeek(FilOpen,0,0) && inicio de Archivo &&
faltasobra=(wcapdisk-lenFop)
IF faltasobra < 0
byteslee=(lenFop-((lenFop-wcapDisk)+50)) && caracteres a leer &&
ciclo=.t.
leidos=0
op2x=0
do While ciclo
cadlee=fRead(FilOpen,byteslee) && cadena de caracteres leidos &&
targetFile=fCreate('&wDest') && crea archivo destino &&
If TargetFile = -1
=MessageBox('El Archivo Destino no Puede Generarse...Proceso Terminado',0+64+0,'Error')
vr=.f.
Exit
Endif
cControl=fWrite(targetfile,Cadlee) && Graba cadena leida en Destino &&
If cControl =0
=MessageBox('El Archivo Destino no puede ser Escrito...Proceso Terminado',0+64+0,'Error')
vr=.f.
Exit
Endif
fClose(targetFile)
leidos=leidos+byteslee && caracteres leidos &&
cBytes=(lenFop-leidos) && caracteres por leer &&
If cBytes = 0
ciclo=.f.
Loop
Endif
xDisco=xdisco+1
op=MessageBox('Inserte el Disco Numero '+Str(xDisco,2),0+64+0,'Atencion')
If verUndRes() = 0
Wait Windows 'Respaldo Inconcluso <CANCELADO>'
vr=.f.
Exit
Endif
If GenID() = 0
Exit
Endif
wcapdisk=diskSpace('&xUnd')
If File(wDest)
If Op2x = 0 .or. Op2x <> 3
do form forma_Botones with wDest to op2x
Endif
If Op2x = 4
Exit
Endif
If Op2x = 3 .or. Op2x = 1
DelFile(wDest)
Endif
If Op2x = 2
Ciclo=.f.
Loop
Endif
Endif
If cbytes >= wcapDisk
byteslee=(cbytes-((cbytes-wcapdisk)+50)) && caracteres a leer &&
Else
byteslee=cbytes
Endif
puntero=fSeek(FilOpen,0,1)
Enddo
If op2x=4
Exit
Endif
Else
&& Archivo Destino &&
cadLee=fRead(FilOpen,LenfOp)
TargetFile=fCreate('&wDest')
IF TargetFile = -1
=MessageBox('El Archivo Destino no Puede Generarse....Proceso Terminado',0+64+0,'Error')
vr=.f.
Exit
Endif
cControl=fWrite(targetFile,cadlee)
If cControl = 0
=MessageBox('El Archivo Destino no Puede ser Escrito...Proceso Terminado',0+64+0,'Error')
vr=.f.
Exit
Endif
Endif
fclose(FilOpen)
fclose(TargetFile)
Endif
Next
=MessageBox('Respaldo Concluido',0+64+0,'Atencion')
Exit
Enddo
Deactivate Windows Respaldo
Release Windows Respaldo
Retu vr
Function GenID()
aa=.t.
do While aa
If File('&drv_resp'+'I_D.ids')
op=MessageBox('Este Disco Contiene un Respaldo,Continuamos ?',3+64+0,'Atencion')
If op = 2
Retu 0
Endif
If Op =6
fD=Alltrim(drv_resp)+'I_d.ids'
Erase &fd
aa=.f.
Endif
Endif
aa=.f.
Enddo
wId=FCreate('&drv_resp'+'I_D.ids',0)
If wId = -1
Wait Windows 'A Ocurrido un Error de Escritura en el Disco '+Str(Ferror(),5)
Retu 0
Endif
Fwrite(wId,'Dsk_'+Str(xdisco,2)+'/'+Str(wInt,2))
Fclose(wId)
aa=.f.
Retu 1
Function verUndRes()
aa=.t.
Do While aa
xFil=ADir(xUnidf,'&drv_Resp'+'*.*')
If xFil <> 0
xre=MessageBox('El Disco con Informacion o Archivos, Deseas Borrar ?',3+32+0,'Atencion')
If xre = 7
Wait Windows ' Cambie el Disco e Intente de Nuevo ...'
Loop
Endif
If xre = 6
For j = 1 to xFil
archivo=Alltrim(drv_resp)+xunidf(j,1)
DelFile(Archivo)
Next j
Endif
If xre = 2
Retu 0
Endif
Endif
aa=.f.
Enddo
wcapdisk=diskSpace(Substr(drv_resp,1,1))
Retu 1
Function calcDsk()
wsumB=0
For xlis = 1 to Alen(wDirec,1)
xExt=Right(wDirec(xLis,1),3)
If xExt = 'DCT' .Or. xExt = 'DBF' .Or. xExt = 'DCX' .Or. xExt = 'DBC' .Or. xExt = 'CDX' .Or. xExt = 'FPT' .or. xExt = 'TBK'
tamf=(wDirec(xLis,2))
wSumb=wSumb+tamf
Endif
Next
wSumb=wSumb/xcapdsk
wInt=Int(wsumb)
wdec=Substr(Str(wSumb,10,7),at('.',Str(wSumb,10,7))+1,7)
If val(wdec) > 0
wInt=wInt+1
Endif
@ 1,10 say 'No. de Discos Aproximados:'+str(wInt,3)
Retu
Function DelFile
Param xFop
@ 5,2 say 'Eliminando '+xFop
Erase &xfop
@ 5,2 say Space(40)
Retu