DIRECTORY Feedback, FeedbackTypes, FileNames, FS, GGFileOps, Imager, InterpressInterpreter, IO, IPMaster, PFS, Rope, SystemNames; GGFileOpsImpl: CEDAR PROGRAM IMPORTS Feedback, FileNames, FS, Imager, InterpressInterpreter, IO, IPMaster, PFS, Rope, SystemNames EXPORTS GGFileOps = BEGIN MsgRouter: TYPE = FeedbackTypes.MsgRouter; GetGenericFileName: PUBLIC PROC [opRope, fileName, wDir, defaultExt: Rope.ROPE, illegalExts: LIST OF Rope.ROPE, router: MsgRouter, emergency: BOOL ¬ FALSE] RETURNS [fullName: Rope.ROPE ¬ NIL, success: BOOL ¬ TRUE, versionSpecified: BOOL ¬ FALSE] = { cp: FS.ComponentPositions; extRope: Rope.ROPE; versionSpecified ¬ Rope.SkipTo[s: fileName, skip: "!"]#Rope.Length[fileName]; IF Rope.Equal[fileName, NIL] THEN { success ¬ FALSE; IF NOT emergency THEN Feedback.PutF[router, oneLiner, $Complaint, "%g failed: no file name specified", [rope[opRope]] ]; RETURN; }; [fullName, cp, ] ¬ FS.ExpandName[fileName, wDir ! FS.Error => { success ¬ FALSE; IF NOT emergency THEN Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: FS Error during name expansion of %g", LIST[[rope[opRope]], [rope[fileName]]] ]; CONTINUE; } ]; IF NOT success THEN RETURN; extRope ¬ Rope.Substr[base: fullName, start: cp.ext.start, len: cp.ext.length]; FOR ropeList: LIST OF Rope.ROPE ¬ illegalExts, ropeList.rest UNTIL ropeList=NIL DO IF Rope.Equal[ropeList.first, extRope, FALSE] THEN { success ¬ FALSE; IF NOT emergency THEN Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: %g extension for %g files not allowed", LIST[[rope[opRope]], [rope[extRope]], [rope[defaultExt]]] ]; RETURN; }; ENDLOOP; IF cp.ext.length=0 THEN fullName ¬ Rope.Cat[fullName, ".", defaultExt]; fullName ¬ FileNames.ResolveRelativePath[fullName]; }; FNameToGName: PUBLIC PROC [name: Rope.ROPE] RETURNS [Rope.ROPE] = { gHost, gDir: Rope.ROPE; IF Rope.Match["[]*", name] THEN { gHost ¬ Rope.Cat["[", SystemNames.MachineName[], "]"]; gDir ¬ Rope.Cat[gHost, "<", --File.GetVolumeName[File.SystemVolume[]],-- ">"]; IF Rope.Match["[]<>*", name] THEN RETURN [Rope.Replace[base: name, start: 0, len: 4, with: gDir]] ELSE RETURN [Rope.Replace[base: name, start: 0, len: 2, with: gHost]]; }; RETURN [name]; }; PeriodBreakProc: SAFE PROC [char: CHAR] RETURNS [IO.CharClass] = { SELECT char FROM '. => RETURN[sepr]; ENDCASE => RETURN[other]; }; FilenameMinusExtension: PUBLIC PROC [wholeName: Rope.ROPE] RETURNS [firstPart: Rope.ROPE] = { wholeStream: IO.STREAM ¬ IO.RIS[wholeName]; [firstPart, ----] ¬ IO.GetTokenRope[wholeStream, PeriodBreakProc]; }; GetInterpressFileName: PUBLIC PROC [opRope, ipName: Rope.ROPE, currentWDir: Rope.ROPE, router: MsgRouter] RETURNS [fullName: Rope.ROPE ¬ NIL, success: BOOL ¬ TRUE] = { [fullName, success, ----] ¬ GetGenericFileName[opRope, ipName, currentWDir, "ip", LIST["gargoyle", "script", "mesa", "tioga"], router]; }; GetGargoyleFileName: PUBLIC PROC [opRope, ggName: Rope.ROPE, currentWDir: Rope.ROPE, router: MsgRouter, emergency: BOOL ¬ FALSE] RETURNS [fullName: Rope.ROPE ¬ NIL, success: BOOL ¬ TRUE, versionSpecified: BOOL ¬ FALSE] = { [fullName, success, versionSpecified] ¬ GetGenericFileName[opRope, ggName, currentWDir, "gargoyle", LIST["ip", "interpress", "script", "mesa", "tioga"], router, emergency]; }; GetScriptFileName: PUBLIC PROC [opRope, scriptName: Rope.ROPE, currentWDir: Rope.ROPE, router: MsgRouter] RETURNS [fullName: Rope.ROPE ¬ NIL, success: BOOL ¬ TRUE] = { [fullName, success, ----] ¬ GetGenericFileName[opRope, scriptName, currentWDir, "script", LIST["gargoyle", "ip", "interpress", "mesa", "tioga"], router]; }; OpenInterpressOrComplain: PUBLIC PROC [opRope: Rope.ROPE, router: MsgRouter, fullName: Rope.ROPE] RETURNS [ipMaster: InterpressInterpreter.Master, success: BOOL ¬ TRUE] = { LogIt: InterpressInterpreter.LogProc = { Feedback.PutFL[router, oneLiner, $Log, "%g: %g", LIST[[rope[opRope]], [rope[explanation]]] ]; }; ipMaster ¬ InterpressInterpreter.Open[fileName: fullName, log: LogIt ! FS.Error => { Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: %g for %g", LIST[[rope[opRope]], [rope[error.explanation]], [rope[fullName]]] ]; GOTO Quit; }; PFS.Error => { -- yuck: maybe InterpressInterpreter.Open shouldn't raise either FS or PFS errors! Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: %g for %g", LIST[[rope[opRope]], [rope[error.explanation]], [rope[fullName]]] ]; GOTO Quit; }; IPMaster.Error => { -- ErrorDesc: TYPE = RECORD[code: ATOM, explanation: ROPE] Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: %g for %g", LIST[[rope[opRope]], [rope[error.explanation]], [rope[fullName]]] ]; GOTO Quit; }; -- need this even with LogProc#NIL Imager.Error => { -- ErrorDesc: TYPE = RECORD [code: ATOM, explanation: ROPE] Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: %g for %g", LIST[[rope[opRope]], [rope[error.explanation]], [rope[fullName]]] ]; GOTO Quit; }; IO.Error, IO.EndOfStream => { Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: IO Stream Error for %g", LIST[[rope[opRope]], [rope[fullName]]] ]; GOTO Quit; }; ]; IF ipMaster=NIL THEN { Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: missing file or IO error for %g", LIST[[rope[opRope]], [rope[fullName]]] ]; GOTO Quit; }; IF ipMaster.pages=0 THEN { Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: zero pages in %g", LIST[[rope[opRope]], [rope[fullName]]] ]; GOTO Quit; }; EXITS Quit => success ¬ FALSE; }; END. GGFileOpsImpl.mesa Copyright Ó 1986, 1988, 1989, 1990, 1992 by Xerox Corporation. All rights reserved. Contents: Routines that manipulate file names or open and close files. Pier, June 24, 1992 10:25 am PDT Bier, March 10, 1990 5:34:06 pm PST Doug Wyatt, April 9, 1992 5:04 pm PDT Generic File Name Operations code copied from CommandTool.OtherCommandsImpl.mesa Convenience File Name Operations for Gargoyle Use Generic File Opening Operations IPInterpreter.Error will no longer be raised, but expect a NIL master to be returned. KAP. June 24, 1992 IPInterpreter.Error => { -- raised if the file is non-existant Feedback.PutFL[router, oneLiner, $Complaint, "%g failed: %g for %g", LIST[[rope[opRope]], [rope[explanation]], [rope[fullName]]] ]; GOTO Quit; }; Êì•NewlineDelimiter –(cedarcode) style˜codešœ™Kšœ ÏeœI™TKšœG™GK™ K™#K™%K™—šÏk ˜ Kšœ$žœ,žœ žœ˜w—K˜šÏn œžœž˜Kšžœžœ!žœ žœ˜dKšžœ ž˜—˜Kšœ žœ˜*—K˜K™šŸœž œ+žœžœžœžœ žœžœžœžœžœ žœžœžœžœ˜ùKšœžœ˜Kšœžœ˜K˜Mšžœžœžœ˜#Kšœ žœ˜K•StartOfExpansionÒ[gargoyleData: REF ANY, msgType: GGError.MsgType, format: ROPE _ NIL, v1: IO.Value _ [null[]], v2: IO.Value _ [null[]], v3: IO.Value _ [null[]], v4: IO.Value _ [null[]], v5: IO.Value _ [null[]]]šžœžœ žœc˜xKšžœ˜Kšœ˜—šœžœžœ ˜?Kšœ žœ˜K–Ò[gargoyleData: REF ANY, msgType: GGError.MsgType, format: ROPE _ NIL, v1: IO.Value _ [null[]], v2: IO.Value _ [null[]], v3: IO.Value _ [null[]], v4: IO.Value _ [null[]], v5: IO.Value _ [null[]]]šžœžœ žœažœ%˜ŸKšžœ˜ K˜Kšœ˜—Kšžœžœ žœžœ˜K–9[base: ROPE, start: INT _ 0, len: INT _ 2147483647]˜Oš žœ žœžœžœžœ žœž˜Ršžœ%žœžœ˜4Kšœ žœ˜Kšžœžœ žœcžœ8˜µKšžœ˜K˜—Kšžœ˜—Kšžœžœ0˜GK˜3K˜K˜—š Ÿ œžœžœ žœžœžœ˜CK™3Kšœžœ˜šžœžœ˜!K˜6KšœÏc,œ˜Nšžœ˜Kšžœžœ9˜DKšžœžœ;˜F—K˜—Kšžœ˜K˜K˜—š Ÿœžœžœžœžœžœ˜Bšžœž˜Kšœžœ˜Kšžœžœ˜—Kšœ˜—š Ÿœžœžœžœžœžœ˜]Kš œ žœžœžœžœ ˜+Kšœ  œžœ,˜BKšœ˜—K˜K™1šŸœžœžœžœžœžœžœžœ žœžœ˜§Kšœ œ:žœ1˜‡K˜K˜—šŸœžœžœžœžœ žœžœžœžœžœ žœžœžœžœ˜ÞKšœdžœD˜¬K˜K˜—šŸœžœžœžœžœžœžœžœ žœžœ˜§Kšœ œBžœ;˜™K˜—K˜K™šŸœžœžœžœ$žœžœ3žœžœ˜¬šŸœ#˜(Kšœ2žœ(˜^K˜—K˜˜FK™jšœ %™>KšœFžœ;™…Kšžœ™ Kšœ™—šžœ ˜ KšœEžœA˜‹Kšžœ˜ Kšœ˜—šžœ  R˜aKšœEžœA˜‹Kšžœ˜ Kšœ˜—šœ :˜NKšœEžœA˜‹Kšžœ˜ Kšœ "˜%—šœ ;˜MKšœEžœA˜‹Kšžœ˜ Kšœ˜—šžœžœ˜KšœSžœ%˜|Kšžœ˜ Kšœ˜—Kšœ˜—šžœ žœžœ˜Kšœ\žœ%˜…Kšžœ˜ Kšœ˜—šžœžœ˜KšœMžœ%˜vKšžœ˜ Kšœ˜—šž˜Kšœžœ˜—K˜K˜—Kšžœ˜K˜—…—*