TestDFClosure.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Created by Bertrand Serlet, October 21, 1986 10:11:12 pm PDT
Bertrand Serlet October 25, 1986 10:36:39 pm PDT
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;
Bringover Defining only
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];
};
BringDAUser
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.