InstallFontsImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Tim Diebert: April 9, 1987 3:13:47 pm PDT
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: BOOLFALSE];
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: ROPENIL;
df: STREAMFS.StreamOpen[remoteName, read ! FS.Error => ERROR Error[error.explanation]];
DFUtilities.ParseFromStream[df, ProcessItem];
IO.Close[df];
END;
END.