<> <> <> <> <<>> DIRECTORY DFClosure, DFUtilities, FS, IO, MessageWindow, Rope; TestDFClosure: CEDAR PROGRAM IMPORTS DFUtilities, FS, IO, MessageWindow, Rope ~ BEGIN OPEN DFClosure; ROPE: TYPE ~ Rope.ROPE; ROPES: TYPE ~ LIST OF ROPE; STREAM: TYPE = IO.STREAM; <> BringDefiningFile: FileProc = { out: STREAM = NARROW [data]; out.PutF["Copy %g from %g of %g.\n", IO.rope[name], IO.rope[from], IO.time[date.gmt]]; }; BringDefiningImport: ImportProc = {RETURN [none]}; BringDefiningError: ErrorProc = { out: STREAM = NARROW [data]; out.PutF[message]; }; <> BringDAUserFile: FileProc = { out: STREAM = NARROW [data]; localName: ROPE = DFUtilities.RemoveVersionNumber[name]; BEGIN attachedTo: ROPE; created: BasicTime.GMT; [attachedTo: attachedTo, created: created] _ FS.FileInfo[name: localName, remoteCheck: FALSE ! FS.Error => GOTO Copy]; -- if the file is inexistent, we copy it! IF attachedTo=NIL THEN {out.PutF["File %g NOT copied from %g: local version exists.\n", IO.rope[name], IO.rope[from]]; RETURN}; IF created=date.gmt THEN RETURN; -- already there IF LOOPHOLE[created, INT]>LOOPHOLE[date.gmt, INT] THEN {out.PutF["File %g NOT copied from %g: local version more recent.\n", IO.rope[name], IO.rope[from]]; RETURN}; GOTO Copy; EXITS Copy => [] _ FS.Copy[ to: localName, from: Rope.Cat[from, name], wantedCreatedTime: date.gmt, attach: TRUE ! FS.Error => out.PutF["File %g could NOT be copied from %g: %g.\n", IO.rope[localName], IO.rope[from], IO.rope[error.explanation]]; ]; END; }; BringDAUserImport: ImportProc = {RETURN [IF Rope.Match["/DATools/*", dfName] OR Rope.Match["[DATools]*", dfName] THEN all ELSE public]}; BringDAUserMessage: MessageProc = {MessageWindow.Append[message, TRUE]}; END.