<> <> <> DIRECTORY DFUtilities USING [DirectoryItem, FileItem, ParseFromStream, ProcessItemProc], FS USING [ComponentPositions, Copy, Error, ExpandName, StreamOpen], IO USING [Close, PutF, rope, STREAM], Rope USING [ROPE, Substr]; InstallFontsImpl: CEDAR PROGRAM IMPORTS DFUtilities, FS, IO, Rope EXPORTS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; STREAM: TYPE ~ IO.STREAM; Error: PUBLIC ERROR[reason: ROPE] = CODE; Install: PUBLIC PROC [out: STREAM, localDir: ROPE, remoteName: ROPE] = BEGIN ProcessItem: DFUtilities.ProcessItemProc = BEGIN <<[item: REF ANY] RETURNS [stop: BOOL _ FALSE];>> WITH item SELECT FROM dir: REF DFUtilities.DirectoryItem => {root _ dir.path1}; file: REF DFUtilities.FileItem => { fullFName, toName: ROPE; cp: FS.ComponentPositions; [fullFName, ] _ FS.ExpandName[name: file.name, wDir: root]; [toName, cp] _ FS.ExpandName[name: file.name, wDir: localDir]; toName _ Rope.Substr[base: toName, start: 0, len: cp.ver.start-1]; toName _ FS.Copy[from: fullFName, to: toName, setKeep: TRUE, keep: 1, attach: FALSE]; -- don't attach it IO.PutF[out, "Copied %g => %g\n", IO.rope[fullFName], IO.rope[toName]]; }; ENDCASE => NULL; END; root: ROPE _ NIL; df: STREAM _ FS.StreamOpen[remoteName, read ! FS.Error => ERROR Error[error.explanation]]; DFUtilities.ParseFromStream[df, ProcessItem]; IO.Close[df]; END; END.