PrintADFFile:
PROC [cmd: Commander.Handle]
RETURNS [result:
REF
ANY ←
NIL, msg:
ROPE ←
NIL]
--Commander.CommandProc-- =
BEGIN
commandLineStream: IO.STREAM ← IO.RIS[cmd.commandLine];
dfName: ROPE ← commandLineStream.GetTokenRope[IO.IDProc].token;
switches: ROPE ← commandLineStream.GetLineRope[];
dfStream: IO.STREAM ← NIL;
printCommand: ROPE ← Rope.Cat["Print ", switches];
dir: ROPE ← "!?No Directory?!";
PerItem:
PROC [item:
REF
ANY]
RETURNS [stop:
BOOL ←
FALSE] = {
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"];