<<>> <> <> <> <<>> DIRECTORY Commander, PFS, Rope, PFSNames, IO, CommanderOps; FindAttachmentsCommand: CEDAR PROGRAM IMPORTS Commander, PFS, PFSNames, IO, Rope, CommanderOps ~ BEGIN Command: Commander.CommandProc ~ { star: PFS.PATH ~ PFS.PathFromRope["*"]; pats: LIST OF PFS.PATH ¬ NIL; Recurse: PROC ~ { PFS.EnumerateForInfo[pattern: star, proc: Each] }; Each: PFS.InfoProc ~ { IF fileType = PFS.tDirectory AND attachedTo = NIL THEN { PFS.DoInWDir[fullFName, Recurse]; } ELSE { IF attachedTo # NIL THEN { FOR tail: LIST OF PFS.PATH ¬ pats, tail.rest UNTIL tail = NIL DO IF PFSNames.IsAPrefix[tail.first, attachedTo].isa THEN { IO.PutRope[cmd.out, PFS.RopeFromPath[fullFName]]; IO.PutRope[cmd.out, "\n"]; RETURN }; ENDLOOP; }; }; }; FOR each: Rope.ROPE ¬ CommanderOps.NextArgument[cmd], CommanderOps.NextArgument[cmd] UNTIL each = NIL DO pats ¬ CONS[PFS.PathFromRope[Rope.Concat["-ux:", each]], pats]; ENDLOOP; IF pats = NIL THEN CommanderOps.Failed[cmd.procData.doc]; PFS.EnumerateForInfo[pattern: star, proc: Each]; }; Commander.Register["FindAttachments", Command, "Lists all files under current WD that have attachments (links) to the listed directories"]; END.