DIRECTORY CedarSnapshot, FileIO, IO, Process, Rope, MessageWindow, UserCredentials, ViewerClasses, ViewerEvents; MaintainFilesList: CEDAR MONITOR IMPORTS CedarSnapshot, FileIO, IO, Process, Rope, MessageWindow, UserCredentials, ViewerEvents = { regProc: REF; filesList: Rope.ROPE; userName: Rope.ROPE = UserName[]; fileName: Rope.ROPE = Rope.Concat[userName, ".List"]; UserName: PROC RETURNS [name: Rope.ROPE] = { dot: INT; name _ UserCredentials.GetUserCredentials[].name; dot _ Rope.Find[name, "."]; IF dot > 0 THEN name _ Rope.Substr[name, 0, dot] }; Add: ViewerEvents.EventProc = TRUSTED { Process.Detach[FORK AddToFilesList[viewer.name]] }; AddToFilesList: ENTRY PROC [name: Rope.ROPE] = { ENABLE UNWIND => NULL; AlreadyThere: PROC RETURNS [BOOL] = { pos: INT _ 0; len: INT = Rope.Size[name]; fileLen: INT = Rope.Size[filesList]; blank: CHAR = ' ; WHILE (pos _ Rope.Find[filesList, name, pos, FALSE]) # -1 DO -- look for adjacent blanks IF (pos>0 AND Rope.Fetch[filesList, pos-1] # blank) OR (pos+len < fileLen AND Rope.Fetch[filesList, pos+len] # blank) THEN { pos _ pos+len; LOOP }; RETURN [TRUE]; ENDLOOP; RETURN [FALSE] }; IF Rope.Size[name]=0 THEN RETURN; IF Rope.Equal[name, fileName, FALSE] THEN { -- record hand change to file holding list GetFilesList[]; RETURN }; IF AlreadyThere[] THEN RETURN; MessageWindow.Append["Adding ", TRUE]; MessageWindow.Append[name]; MessageWindow.Append[" to "]; MessageWindow.Append[fileName]; filesList _ Rope.Concat[filesList, Rope.Concat[" ", name]]; WriteFilesList[]; }; WriteFilesList: PROC = { OPEN IO; ENABLE UNWIND => NULL; s: STREAM _ FileIO.Open[fileName, overwrite]; PutRope[s, filesList]; Close[s] }; AfterRollback: PROCEDURE [when: CedarSnapshot.After] = { IF when=checkpoint THEN RETURN; GetFilesList[] --update cached copy-- }; GetFilesList: PROC = { s: IO.STREAM = FileIO.Open[fileName, read ! FileIO.OpenFailed => {IF why=fileNotFound THEN GOTO Quit}]; len: INT = IO.GetLength[s]; readChar: SAFE PROC RETURNS [CHAR] = { RETURN [IO.GetChar[s]] }; filesList _ Rope.FromProc[len, readChar]; IO.Close[s]; EXITS Quit => filesList _ NIL; }; UnReg: ENTRY PROC = { ENABLE UNWIND => NULL; IF regProc # NIL THEN ViewerEvents.UnRegisterEventProc[regProc, save]; regProc _ NIL; filesList _ NIL }; Reg: ENTRY PROC = { ENABLE UNWIND => NULL; IF regProc # NIL THEN ViewerEvents.UnRegisterEventProc[regProc, save]; regProc _ ViewerEvents.RegisterEventProc[Add, save]; GetFilesList[] }; Reg[]; TRUSTED {CedarSnapshot.Register[r: AfterRollback]}; }... ä--MaintainFilesList.mesa -- Last changed by Paxton, August 31, 1982 4:16 pm -- Last changed by McGregor, September 10, 1982 2:21 pm Last Edited by: Maxwell, January 6, 1983 12:19 pm Michael Plass, August 12, 1983 11:48 am Êœ˜JšÏc™Jš2™2Jš7™7J™1J™'JšÏk ˜ J˜Jšž˜Jšžœ˜J˜J˜J˜Jšœ˜J˜J˜ J˜Jšœž ˜ JšžœžœžœA˜bJ˜Jšœ žœ˜ Jšœžœ˜Jšœžœ˜!Jšœžœ"˜5J˜šÏnœžœžœ žœ˜,Jšœžœ˜ Jšœ1˜1J˜Jšžœ žœ$˜3J˜—Jšœžœžœ ˜[J˜šŸœžœžœ žœ˜0Jšžœžœžœ˜šŸ œžœžœžœ˜%Jšœžœ˜ Jšœžœ˜Jšœ žœ˜$Jšœžœ˜šžœ(žœžœ˜Xšžœžœ'ž˜6Jšœžœ(˜>Jšžœžœ˜—Jšžœžœ˜Jšžœ˜—Jšžœžœ˜—Jšžœžœžœ˜!šžœžœžœ*˜VJšœžœ˜—Jšžœžœžœ˜Jšœ žœ˜&J˜J˜J˜J˜;Jšœ˜J˜J˜—šŸœžœžœžœ˜!Jšžœžœžœ˜Jšœžœ$˜-J˜J˜ J˜—šŸ œ+˜8J˜Jšœ(˜(J˜—šŸ œžœ˜šœžœžœ˜+Jšœžœžœžœ˜;—Jšœžœžœ˜Jš œ žœžœžœžœžœžœ˜@J˜)Jšžœ ˜ Jšžœžœ˜J˜J˜—šŸœžœžœ˜Jšžœžœžœ˜Jšžœ žœžœ1˜FJšœ žœ˜Jšœ žœ˜J˜—šŸœžœžœ˜Jšžœžœžœ˜Jšžœ žœžœ1˜FJ˜4J˜J˜—J˜Jšžœ,˜3J˜J˜—…— ÎN