PrintDF.Mesa
Last Edited by: Spreitzer, August 18, 1984 11:11:43 pm PDT
DIRECTORY Commander, CommandTool, DFUtilities, FS, IO, Rope;
PrintDF: CEDAR PROGRAM
IMPORTS Commander, CommandTool, DFUtilities, FS, IO, Rope =
BEGIN
ROPE: TYPE = Rope.ROPE;
PrintADFFile: PROC [cmd: Commander.Handle] RETURNS [result: REF ANYNIL, msg: ROPENIL] --Commander.CommandProc-- =
BEGIN
commandLineStream: IO.STREAMIO.RIS[cmd.commandLine];
dfName: ROPE ← commandLineStream.GetTokenRope[IO.IDProc].token;
switches: ROPE ← commandLineStream.GetLineRope[];
dfStream: IO.STREAMNIL;
printCommand: ROPE ← Rope.Cat["Print ", switches];
dir: ROPE ← "!?No Directory?!";
PerItem: PROC [item: REF ANY] RETURNS [stop: BOOLFALSE] = {
WITH item SELECT FROM
di: REF DFUtilities.DirectoryItem => dir ← di.path1;
fi: REF DFUtilities.FileItem => printCommand ← printCommand.Cat[" ", dir, fi.name];
ii: REF DFUtilities.ImportsItem => NULL;
ii: REF DFUtilities.IncludeItem => NULL;
wi: REF DFUtilities.WhiteSpaceItem => NULL;
ENDCASE => ERROR};
commandLineStream.Close[];
dfStream ← FS.StreamOpen[dfName !FS.Error => {msg ← IO.PutFR["FS.Error[code: %g, explanation: %g]", IO.atom[error.code], IO.refAny[error.explanation]]; CONTINUE}];
IF dfStream = NIL THEN RETURN [$Failure, msg];
DFUtilities.ParseFromStream[in: dfStream, proc: PerItem];
dfStream.Close[];
result ← CommandTool.DoCommand[commandLine: printCommand, parent: cmd];
END;
Commander.Register[key: "PrintDF", proc: PrintADFFile, doc: "Print all the files mentioned in a DF file"];
END.