UFFileTester.mesa
Last Edited by Michael Plass, January 13, 1983 11:31 am
DIRECTORY UFFileManager, UserExec, IO, Random, Rope;
UFFileTester: CEDAR PROGRAM
IMPORTS UFFileManager, UserExec, IO, Random
= BEGIN
numberOfOpenFiles: NAT = 10;
numberOfFileNames: NAT = 15;
fileName: ARRAY [0..numberOfFileNames) OF Rope.ROPE = [
"/indigo/pressfonts/TimesRoman-mrr.sd",
"/indigo/pressfonts/TimesRoman-mir.sd",
"/indigo/pressfonts/TimesRoman-bir.sd",
"/indigo/pressfonts/TimesRoman-brr.sd",
"/indigo/tioga/tfm/TCLogo.TFM",
"/indigo/tioga/tfm/TEMPLATE.TFM",
"/indigo/tioga/tfm/TESTFONT12.TFM",
"/indigo/tioga/tfm/TimesRoman.TFM",
"/indigo/tioga/tfm/TimesRoman12.TFM",
"/indigo/tioga/tfm/TimesRoman12I.TFM",
"/indigo/tioga/tfm/TimesRoman14.TFM",
"/indigo/tioga/tfm/TimesRoman18.TFM",
"/indigo/tioga/tfm/TimesRomanB.TFM",
"/indigo/tioga/tfm/TimesRomanBI.TFM",
"/indigo/tioga/tfm/TimesRomanI.TFM"
];
Test1: PROCEDURE [n: INT] = {
file: ARRAY [0..numberOfOpenFiles) OF UFFileManager.FontFile;
FOR i: INT IN [0..n) DO
slot: [0..numberOfOpenFiles) ← Random.Choose[0, numberOfOpenFiles-1];
fileNo: [0..numberOfFileNames) ← Random.Choose[0, numberOfFileNames-1];
UserExec.GetExecHandle[].GetStreams[].out.PutF["Slot %g request for %g\n", IO.int[slot], IO.rope[fileName[fileNo]]];
file[slot] ← UFFileManager.Open[UFFileManager.KeyOf[fileName[fileNo]]];
ENDLOOP;
FOR i: INT IN [0..numberOfOpenFiles) DO
file[i] ← NIL;
ENDLOOP;
};
Test2: PROCEDURE [] = {
file: UFFileManager.FontFile;
fileUFFileManager.Open[UFFileManager.KeyOf[fileName[1]]];
file ← NIL;
};
trueSeed: INT ← Random.Init[];
fontFileWatcher: UFFileManager.FontFileWatcher = {
actionMsg: Rope.ROPESELECT action FROM
open => "Opened",
close => "Closed",
openFailed => "Failed to open",
ENDCASE => ERROR;
UserExec.GetExecHandle[].GetStreams[].out.PutF["%g file %g\n", IO.rope[actionMsg], IO.rope[UFFileManager.NameOf[key]]];
};
UFFileManager.RegisterFontFileWatcher[fontFileWatcher];
END.