> Deleter1 , v1.00 20-Nov-2001 JGH: Initial version 7 Goes through Zip file, comparing to dir structure (< Produces a deletefile to remove objects not in zipfile 2 Needs a better name <4 Needs to strip terminal "." from dir leafnames F: P: ZE ctrl%30,data%80,extra%128,zp%6:A$=OS_GetEnv:in%=0:out%=0:sj%=0 d info% 39,metadata% 127 n7quit$=cl(" -q",1):debug%=cl("-de",0): ::end xS cl("-?",0):"Syntax: *Deleter infile -d path -f -u -v -X -quit command":end Gfsh%=cl("-f",0):upd%=cl("-u",0):dest$=cl("-d",1):vb%=cl("-v",0) "xtr%=cl("-X",0):in$=cl("",0) debug%:" run$='"run$"'"'"quit$='"quit$"'"'" in$='"in$"'"'"dest$='"dest$"'"'"freshen=";fsh%;" update=";upd%;" verbose=";vb% : ' :CloseAll:" at line ";:end X%=ctrl%:Y%=X%256:fln%=11 )max%=--6000: mem% max%:wr%=2:rd%=4 l in$="":"Zipfile to reference: "in$: dest$="":"Destination path: "dest$:"Output deletefile: "dfile$ 5in%=(in$): in%=0:"File '"in$"' not found":end : get32<>&04034B50:"Not a ZIP file":#in%:in%=0:end path$=dest$ Eout%=(dfile$):#out%,"| Deletefile to remove unreferenced files" Scan ,#out%:out%=0:"SetType "+dfile$+" Obey" #in%:in%=0  ": , Scan 6 index%,num% @=ș "OS_GBPB",9,path$,info%,1,index%,39,0 ,,,num%,index% J+ info%=>load,exec,len,attr,type,name+0 Tnum%<>0:Object ^ num%=0: h: r Object |7info%?39=13:fn$=$(info%+20):fn$=fn$,fn$+0,0)-1) #id%=get32:id%=&04034B50:file          :done%= " id%=&02014B50:dir:done%= " id%=&06054B50:eof:done%= 6 done%:#in%=#in%-5:"Damaged ZIP file?";13; + id%=&02014B50 id%=&06054B50 #in% #in%:in%=0  end: &: 0CloseAll:*Exec :#in%=in%: in%:A%=in%:in%=0:#A% D(out%=out%: out%:A%=out%:out%=0:#A% N#md%=md%: md%:A%=md%:md%=0:#A% X b: l file v4verneeded%=get16:flags%=get16:comptype%=get16 +mtime%=get16:mdate%=get16:crc%=get32 %compsize%=get32:filesize%=get32 $namelen%=get16:extralen%=get16 *name$="": x%=0 127 4:extra%!x%=0: 6 namelen%: x%=1 namelen%:name$=name$+ #in%: 6 extralen%: x%=0 extralen%-1:extra%?x%=#in%: !hdrid%=ex16(0):dsz%=ex16(2) @sig%=extra%!4:load%=extra%!8:exec%=extra%!12:attr%=extra%!16 Cctime%=ex16(24):cdate%=ex16(26):acc%=ex16(28):aux%=ex16(30) / hdrid%=&4341 -> Created on Acorn computer 2 dsz% usually =&14, ie 20 bytes of extra data  sig%='ARC0' -> Archive *name$=convertname(name$): name$;" ";       *exMeta:: 4: >: Hunzipfile R exMeta \ensurepath(dest$+name$) fpath$=dest$+name$ pA%= path$: z%A%=A%-1: path$,A%,1)="." A%<2 >leaf$=path$,A%+1): leaf$,1)=".":leaf$=leaf$, leaf$-1) path$=path$,A%)  MetaData contents: D NAME+SPC TAB LOAD EXEC LEN ACC mDATE mTIME cDATE cTIME ACC AUX C 10 1 4 4 4 1 2 3 2 3 2 2 . Dates and times are in fileserver format : 2 cdate, ctime, mdate, mtime are in ZIP format / Need to be outputted in fileserver format : @info%!0=load%:info%!4=exec%:info%!8=filesize%:info%!12=attr% 5info%!13=fsDate(mdate%):info%!15=fsTime(mtime%) 5info%!18=fsDate(cdate%):info%!20=fsTime(ctime%) *info%!23=acc%:info%!25=aux%:info%!28=0 :  filename$=leaf$:mpath$=path$ $SetExtras(27,crc%) .4#in%=#in%+compsize%:(flags%8):#in%=#in%+12 8 B#"Write to ";path$;"!!MetaData" L leaf$+" ",10);9; V; h0(load%,8)h0(exec%,8)h0(filesize%,8)h0(attr%,2); `3 h0(fsDate(mdate%),4)h0(fsTime(mtime%),6); j3 h0(fsDate(cdate%),4)h0(fsTime(ctime%),6); t h0(acc%,4)h0(aux%,4) ~ ; 7ݤfsDate(A%): Convert ZIP format date to FS format  yr%,mn%,dy% >dy%=A% &1F:mn%=(A% &1E0)32:yr%=1980+(A% &FE00)&200 ;yr%=yr%-1981:=dy% mn%*256 (yr%15)*&1000 (yr%&70)*2 : 7ݤfsTime(A%): Convert ZIP format time to FS format  hr%,mn%,sc% 7sc%=(A%&1F)*2:mn%=(A%&3E0)32:hr%=(A%&F800)&800 =hr%+256*mn%+65536*sc% : + name$,1)=".":: Should set dir info 8"Save "+dest$+name$+" 0+"+~(min(filesize%,&F000))  *out%=0: filesize%:out%=(dest$+name$) 3 comptype%=0:extract comptype%=8:inflate (flags%8):#in%=#in%+12 ()8,8,8:"Done.";: out%:#out%:out%=0 2L hdrid%=&4341:X%!2=load%:X%!6=exec%:X%!14=attr%:A%=file(dest$+name$,1) <. dsz%<25 xtr%=0:: No additional extras F PRINT"mTime: ";~mtime% P PRINT"mDate: ";~mdate% Z PRINT"cTime: ";~ctime% d PRINT"cDate: ";~cdate% n?(sj%3):"Account "+dest$+name$+" "+~acc%+" ("+~aux%+")" x :  extract:"Extracting ...";  trans: : inflate:"Inflating ..."; #in%=#in%+compsize%: : /ݤconvertname(A$): A$,".")+A$,"/")=0:=A$ J A%=1 A$:B%= A$,A%,1):(B%&FE)=46:A$=A$,A%-1)+(B%1)+A$,A%+1) !:A%=0::B%=A$+".",".",A%+1) 1 B%-A%>fln%:A$=A$,A%+10)+A$,B%):B%=A%+fln% A%=B%: B%>= A$:=A$ : Fensurepath(A$): A$="FILE" or ="DIR.DIR.DIR.FILE" or ="DIR.DIR."  A$,".")=0: :A$=A$+".": A$=A$, A$-1): A$,1)=".":A$=A$, A$-1) " file(A$,5)=2: ,B$=A$:A$="": 6F B$<>"":A%=B$+".","."):A$=A$+".",A$<>"")+B$,A%-1):B$=B$,A%+1) @ file(A$,5)<>2:"CDir "+A$ J B$="": T: ^ dir: h eof: r: |5CheckFS: X%,Y%:X%=data%:Y%=X%256:sj%=0:A%=fs  A%=16:sj%=1:  A%<>5: &!X%=&19002000:X%!4=0:A%=&14:&FFF1  $(X%+4),"SJ"):sj%=2:  :  ݤget32 9zp%?0=#in%:zp%?1=#in%:zp%?2=#in%:zp%?3=#in%:=!zp%  ݤget16 =#in%+(&100*#in%) : 6ݤsofar(A%,B%):8,8,8: d0(100*A% B%,2);"%";:="" $ݤd0(A%,N%)="00000000"+ A%,N%) #ݤh0(A%,N%)="0000000"+~A%,N%) "ݤmin(A%,B%): A%filesize%:len%=filesize%-ptr% D/gbpb(rd%,in%,mem%,len%,ptr%): PROCCalcCRC N$gbpb(wr%,out%,mem%,len%,#out%) X>ptr%=ptr%+len%: ptr%>=filesize%: crc%=FNrev32(crc%)EOR-1 b l: v#gbpb(A%,chn%,addr%,num%,ptr%) 5!X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%: &FFD1: !ݤfs: A%,Y%,E%:=(&FFDA)&FF : put32(A%):!&70=A% 5#out%,?&70:#out%,?&71:#out%,?&72:#out%,?&73: put16(A%):!&70=A% #out%,?&70:#out%,?&71: : /end: quit$<>"":A$=quit$:quit$="":os(A$) : Bݤfile(A$,A%):$data%=A$:?X%=data%:X%?1=data%256:=(&FFDD)&FF 7ݤOS_GetEnv: A$:A%=0:X%=1:os%=((&FFF4)&FF00)256 B os%=6>&8000:ș"OS_GetEnv"A$:A$=A$,1+A$," ",1+A$," ")))  os%=32:A$=$&100  6 A$=0:?(P-3):A$=$&600 A$=0:A$=$(+&300) HA%=0: A%=A%+1: A%= A$ A$,A%)<32 A$,A%)>126: A%<> A$:A$=""  8A%=A$+" "," "):run$=A$,A%-1): run$<>"":=A$,A%+1) *uX%=ctrl%:Y%=X%256:A%=9:?X%=0:X%!1=data%:!data%=0:&FFD1:!data%?data%+data%?2<>8:data%?(1+data%)=13:=$(data%+1) 4="" >Iݤcl(l$,n%): l$="":I%=A$+" "," "):l$=A$,I%-1):A$=s(A$,I%+1)):=l$ H l$=32 A$<>"":A$=" "+A$ RdI%=A$,l$):l$="": I%>0n%>0:l$=A$,A$+" "," ",I%+1)+1): A$,I%,1)<>" ":l$=l$,l$+" "," ")-1) \v I%: A$,I%,1)=" ":A$=A$,2+( A$<>32),I%-2-(I%=1)) I%:A$=A$,I%-1)+A$,A$+" "," ",A$+" "," ",I%)+ l$)+1) f#A$=s(A$): n%:=s(l$) =I%<>0 p,os(A$): A$="" A$=42: A$: A$: z2ݤs(A$): A$,1)=" ": A$=A$,2): A$,1)<>" " / A$,1)=" ": A$=A$, A$-1): A$,1)<>" " =A$ : : : : :  > ArcRead2f 30-01-2000   v2b 12-01-2000 JJR:  v2c - add SCAN, INFO, DEL 1 v2d - Try Ack packets, some Beeb conversion , v2e - DeBeebed, Uses MetaData, PROCdir ! v2f - PROCdir, general tidy :  Error $AckType%=27 .+27:maxmem%=1024*1024:=P+maxmem%+6144 8/defaultRoot$="raFS::Raven.$.Root": "ram:$" B!"Default root: "defaultRoot$ L"Dir "+defaultRoot$ V? file maxmem%,info% 127,txbuf% 127,name% 127,metadata% 127 ` *FX7,8 j *FX8,8 t *FX2,1 ~ start%=:totlen%=0:LastSp%=1   A%=0127 4:info%!A%=0: = PRINT"Command : ";:command$ =FNReadStr:PRINT command$ > PRINT"Filename : ";:filename$=FNReadStr:PRINT filename$ 3"Command : ";:command$ =ReadStr: command$; 'filename$=ReadStr: 17);filename$ blklen%= + blklen%: A%=0blklen%-1:info%?A%=: load% =info%!0 exec% =info%!4 length%=info%!8 attr% =info%!12 DoCommand   : (DoCommand 2 command$="FILE":receive: < command$="DIR" :dir: F% command$="UP" :"Dir ^":Ack: P command$="SET" :SetInfo: Z command$="SCAN":Scan: d command$="INFO":Info: n command$="DEL" :Del: x : Error:ș"Hourglass_Smash" *FX2 *FX3 :" at line ";" "; CloseMD : : #ݤReadStr: a$,b$,c$:b$=13+10 #c$=:ȕ b$,c$)=0:a$+=c$:c$=: =a$ : receive Ack R "Receiving : "filename$" ";length%" bytes. ETA ";length% LastSp%" seconds." d : ș "OS_File",0,filename$,load%,exec%,file,file+length%:"Saved buffer to disk.":Error "& length%>maxmem%:BufferOverrun: ,T%= 6 length% @ș "Hourglass_On" Jtotlen%+=length% T A%=0length%-1 ^ file?A%= hD(A%&FF)=0: length%:ș "Hourglass_Percentage",(100/length%)*A% r |ș "Hourglass_Off"  -ș "XOS_CLI","SetType "+filename$+" Data" $ș "XOS_CLI","Access "+filename$ :ș "OS_File",0,filename$,load%,exec%,file,file+length% 1ș "XOS_File",4,filename$,,,,attr%:SetExtras ' "File : ";filename$" saved." (T%=-T%: T%:LastSp%=100*length% T% X T%:"This file : ";100*length% T%" cps. All files: ";100*(totlen%(-start%))"." Ack   : BufferOverrun +7:"Buffer overrun! Discarding data"; ș "Hourglass_On" R A%=0 length%-1:B%=:(A%&FF)=0:ș "Hourglass_Percentage",(100/length%)*A% &!:ș "Hourglass_Off":Ack:: 0: : dir D< filename$,1)="$" filename$=defaultRoot$+filename$,2) N/ PRINT "Changing to / Creating ";filename$ X filename$,".")=0 b$ ș "XOS_CLI","CDIR "+filename$ l= ș "XOS_File",1,filename$,load%,exec%,,attr%:SetExtras v !ș "XOS_CLI","DIR "+filename$ Ack  : SetInfo 0ș "XOS_File",1,filename$,load%,exec%,,attr% SetExtras Ack  : SetExtras(num%,crc%) K crc%:info%!num%=crc%:num%=num%+4: info%!(num%-4)=0:REM temp'y bugfix ptr%=mdata(filename$) 0 ptr%=-1: md%=0:md%=(mpath$+"!!MetaData")  ptr%=-1:#md%=#md% $A$=filename$+" ",10)+9 % A%=1 A$:#md%, A$,A%,1): *5 BPUT#md%,LEFT$(filename$+" ",10)+CHR$9; 4A A%=0num%-1:#md%, h0(info%?A%,2):#md%, h0(info%?A%,1) >! crc%: A%=num%-5:#md%,":" H:#md%,13:CloseMD R, Attempt to set cdate/ctime/acc/aux/etc \ f pݤmdata(name$) z& ptr%,found%:name$=s(up(name$)) md%=(mpath$+"!!MetaData")  md%=0:=-1  ptr%=#md% CA%=0: metadata%?A%=#md%:A%=A%+1: #md% metadata%?(A%-1)<32 4metadata%?(A%-1)=13: $metadata%=GET$#md%+CHR$13 metadata%?10=13 $found%=s(up($metadata%))=name$  #md% found%  found%:=-1 #md%=ptr% =ptr% :  CloseMD md%=md%: md%:#md%:md%=0  $: . Del 8 "Deleting : "filename$ B,ș "XOS_CLI","Wipe "+filename$+" R~CF~V" LAck V `: j Info t?ș "XOS_File",5,filename$ r0,r1,load%,exec%,length%,attr% ~#ptr%=mdata(filename$):CloseMD %txbuf%?14=attr% ((4*attr%)&44)  ptr%<>-1  mdata$=$(metadata%+11) : A%=0 31:txbuf%?(A%+2)=("&"+mdata$,A%*2+1,2)):  >!txbuf%=r0:txbuf%!2=load%:txbuf%!6=exec%:txbuf%!10=length% 'TxReply(txbuf%,15-15*(ptr%<>-1)): :  Scan  'load%'=index to scan  PRINT "index:";load%  2ș "OS_GBPB",8,0,name%,1,load% ,,,ret%,load%  name%?(1+?name%)=13 ( $(name%+1)<>"!!MetaData" ret%<>0 6!txbuf%=load%:txbuf%!4=ret%:$(txbuf%+8)=$(name%+1) ($TxReply(txbuf%,9+$(name%+1)): 2: <(Ack: AckType%<>27:TxReply(0,0): F *FX3,3 P27 Z*FX3 d n: xTxReply(Addr%,Len%)  *FX3,3  Len% ' Len%: A%=0 Len%-1: Addr%?A%: *FX3  : ݤup(A$): A$="":=""  A%,B$,c%  A%=1 A$:c%= A$,A%,1)  c%>96c%<123:c%=c%-32 B$=B$+ c%::=B$ : ݤs(A$): A$="":=""  c%:ȕ A$,1)=" ":c%+=1: =A$,c%+1,A$+" "," ")-1) : "#ݤh0(A%,N%)="0000000"+~A%,N%)