home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 3
/
TheARMClub_PDCD3.iso
/
hensa
/
disk
/
backup
/
a055_1
/
!Backup
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1993-10-12
|
8KB
|
334 lines
> !RunImage for !Backup Copyright
Denis Howe 1992
You may copy this program freely as long as this
notice is retained and you don't charge for it.
0.00 16-Sep-1991 Written by Denis Howe <dbh@doc.ic.ac.uk>
1.01 13-Feb-1992 Fixed poll loop OpenWindow call
1.02 01-Jun-1992 Added Root$ variable
1.03 20-Dec-1992 Set list filetype to text. Specify file
sys for archive. Add ArcDev$ variable.
Error0
2Root$="adfs::4.$" :
Directory to back up
RootLen%=
(Root$)+2
9ArcDev$="adfs::0.$" :
Where to write the back-up.
Templates file:
LevelWH%=99
!prev_date_ih = 0 :
indirect
prev_level_ih = 1
!this_date_ih = 2 :
indirect
this_level_ih = 3
ok_ih = 4
TaskName$="Backup"
buflen%=512:datelen%=50
buf% buflen%, ind% 100, indend% -1
date% datelen%, prevdate% 5, now% 5, Hex% 17, Caret% 24
$Hex%="0123456789ABCDEF"
LF=10:CR=13:ESC=27
"OS_SWINumberFromString",,"OS_GBPB"
GBPB%
"OS_SWINumberFromString",,"OS_ConvertStandardDateAndTime"
DateStr%
!"Dir$=
VarVal("Obey$Dir") + "."
">Dates$=Dir$+"Dates" :
Dates of previous backups
#4List$=Dir$+"List" :
Files to backup
$9Record$=Dir$+"Record" :
New date file record
%DLabelLeaf$="!!!Label" :
First file to backup (leafname)
&4Label$=Root$+"."+LabelLeaf$ :
Label file path
Templates$=Dir$+"Templates"
Level$="?"
*4?now%=3:
"OS_Word",14,now% :
Get current time
"Wimp_Initialise", 200, &4B534154, TaskName$
Error
Exists(List$)
Exists(Label$)
Existing
GetLevel
"Wimp_Poll", 1<<0
3<<4
3<<1, buf%
reason%
reason%
"Wimp_OpenWindow",,buf%
Quit :
Close window => abort
Click
64
buf%!12=LevelWH%
buf%!16=ok_ih
GotLevel
buf%!24
GotLevel
ESC:
;&
"Wimp_ProcessKey",buf%!24
<
17,18,19:
buf%!16=0
Exists(F$)
F%:F%=
F%>0
E =F%>0
Existing :
Use existing list and label
K%,F%:F%=
(Label$)
Read level from last char of 2nd line of label
#F% :
skip 1st line
Level$=
P-!buf%=0:$(buf%+4)="Use existing list?"+
"Wimp_ReportError",buf%,%10011,TaskName$
Quit :
No button click
Write :
2 = Cancel returns
GetLevel
[5Level$="":
GetRec(Level$, prevdate%) :
Uses buf%
"Wimp_OpenTemplate",,Templates$
$date%="level"
"Wimp_LoadTemplate",,buf%+4,ind%,indend%,-1,date%,0
,,ind%,,,,F%
"Wimp_CloseTemplate"
F%=0
0,"Template not found"
Level$=""
Level$="0"
c. $(buf%!(4+88+32*prev_date_ih+20))="None"
d* $(buf%+4+88+32*prev_level_ih+20)="-"
f8 $(buf%!(4+88+32*prev_date_ih+20))=
Date(prevdate%)
g- $(buf%+4+88+32*prev_level_ih+20)=Level$
i1$(buf%!(4+88+32*this_date_ih+20))=
Date(now%)
j+$(buf%+4+88+32*this_level_ih+20)=Level$
buf%!28=-1
"Wimp_CreateWindow",,buf%+4
LevelWH%
buf%!0=LevelWH%
"Wimp_OpenWindow",,buf%
"Wimp_GetCaretPosition",,Caret%
"Wimp_SetCaretPosition",LevelWH%,this_level_ih,,,-1,
(Level$)
GotLevel
u1buf%!0=LevelWH%:
"Wimp_GetWindowInfo",,buf%
v+Level$=$(buf%+4+88+32*this_level_ih+20)
GetRec(Level$, prevdate%)
MakeRec(Level$)
MkLabel
MkList
Write
MkLabel
Label%
Label%=
(Label$)
#Label%,"Dump "+Root$
#Label%,"Level "+Level$
#Label%,"From "+
Date(prevdate%)
#Label%,"To "+
Date(now%)
#Label%
MkList
List%
"Wimp_CommandWindow",TaskName$
"Creating list for level ";Level$
"From ";
Date(prevdate%)'"To ";
Date(now%)
List%=
(List$)
#List%:
Error
#List%,".c" :
Create archive
#List%,".z" :
Compress
#List%,".M" :
Multi-disk archive
#List%,".v" :
List files written
#List%,"-C" :
Root of files in list
#List%,Root$
Level$="0"
#List%, "*"
Dir(Root$, List%)
#List%
"Settype "+List$+" Text"
MakeRec(Level$)
Make a record for current backup to append to dates file.
F%,I%
(Record$)
#F%,
Level$:
#F%,
read CMOS clock to 5 byte buf.
I%=4
#F%,
Hex((now%?I%)>>4)
#F%,
Hex((now%?I%))
#F%," "+
Date(now%)
GetRec(
Level$, TP%)
Read dates file. Each line contains the Level (char "0".."9")
followed by a space followed by the time as 10 hex digits. Set 5 byte
time pointed to by TP% & Level$ to time and level of last backup at <
Level$. If Level$="" return last backup if any.
F%,I%,L$
!TP%=0:TP%?4=0
(Dates$)
L$=
/
#F%<>
0,"Bad dates file"
4
I%=4
-1:buf%?I%=
("&"+
#F%):
comment$=
7
Level$=""
L$<Level$ !TP%=!buf%:TP%?4=buf%?4
Level$="" Level$=L$
Write
"Filer_OpenDir "+ArcDev$
BArcBase$=ArcDev$+".L"+Level$ :
Start of tar output file name
;Archive$=ArcBase$+"/"+
Today :
Name after today's date
Wipe(ArcBase$+"*",
No confirm for same level
Wipe(ArcDev$+".*",
Confirm other files
Task("Tar -fl "+Archive$+" "+List$)
AppendRec
"Copy "+List$+" "+Dir$+"OList DF~V"
"Remove "+Label$
AppendRec
FR%,FD%
9FR%=
(Record$):
FR%=0
0,"No date record to append"
(Dates$)
FD%=0 FD%=
(Dates$)
#FD%=
#FD%
FD%=0
0,"Can't append date record"
#FD%,
# FR%
#FD%:
#FR%
"Remove "+Record$
Hex(X%)=Hex%?(X%
Date(P%):
DateStr%,P%,date%,datelen%
,P%:?P%=13:=$date%
GetEntry(D$,
Offset%)
GBPB%,11,D$,buf%,1,Offset%,buflen%,0
,,,,Offset%:=Offset%<>-1
After(t1%,t2%)
t1% & t2% point to 5 byte unsigned datestamps, lsb 1st.
t1% points to the file datestamp, t2% to the previous dump date.
To always backup unstamped files -> IF t1%?4=0 AND !t1%=0 THEN=TRUE
I%:I%=4
I%>0
t1%?I%=t2%?I%:I%-=1:
=t1%?I%>t2%?I%
Dir(D$,List%) :
D$ has no trailing "."
F$,G$,P%,Offset%:Offset%=0
GetEntry(D$,Offset%)
) P%=buf%+29:
?P%>32:P%+=1:
:?P%=13
F$=D$+"."+$(buf%+29)
PRINT F$;" type ";buf%!16
buf%!16
file - check date
&
After(buf%+24, prevdate%)
0 G$=
F$,RootLen%) :
Strip "adfs::4.$."
$
Date(buf%+24)
#List%, G$
recurse on directory (reuses buf)
Dir(F$, List%)
>
0,"Unknown object type: "+
(buf%!16)+" for <"+F$+">"
Task(Cmd$)
Next%,Free%
"Wimp_SlotSize",-1,-1
,Next%,Free%
"Wimp_SlotSize",-1,Next%+Free% :
Set next
"Wimp_StartTask",Cmd$+
(Cmd$)," ")
"Wimp_SlotSize",-1,Next% :
Restore old next slot size
VarVal("Sys$ReturnCode")="0"
VarVal(VarName$) :
Variable name without "< >"
"XOS_ReadVarVal",VarName$,buf%,buflen%,0,3
,,L%
L%<0 L%=0
buf%?L%=13
=$buf%
Today
"OS_ConvertDateAndTime",now%,buf%,buflen%,"%DY%MN%YR"+
?P%=CR
=$buf%
Wipe(Spec$, Confirm%)
Flags$
Confirm%
Errors to cmd window, request confirm, verbose
'! $buf%="Other files on disk"
"Wimp_CommandWindow",buf%
Flags$="CV"
+, Flags$="~C~V" :
no confirm or verbose
Don't display errors
"Wipe "+Spec$+" "+Flags$
Error0
$;" @ "+
Error
9%buf%!0=
:$(buf%+4)=
$+" ("+
"Wimp_ReportError",buf%,1,TaskName$
=&108C2
"Wimp_CloseTemplate"
Restore the caret if we have it.
"Wimp_GetCaretPosition",,buf%
!buf%=LevelWH%
"Wimp_SetCaretPosition",Caret%!0,Caret%!4,Caret%!8,Caret%!12,Caret%!16,Caret%!20
"Wimp_CloseDown"