DIRECTORY Feedback, FeedbackTypes, FileNames, FS, GGFileOps, Imager, Interpress, IO, IPMaster, IPInterpreter, PFS, Rope, SystemNames; GGFileOpsImpl: CEDAR PROGRAM IMPORTS Feedback, FileNames, FS, Imager, Interpress, IO, IPMaster, IPInterpreter, 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.PutF[router, oneLiner, $Complaint, "%g failed: FS Error during name expansion of %g", [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.PutF[router, oneLiner, $Complaint, "%g failed: %g extension for %g files not allowed", [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: Interpress.Master, success: BOOL _ TRUE] = { LogIt: Interpress.LogProc = { Feedback.PutF[router, oneLiner, $Log, "%g: %g", [rope[opRope]], [rope[explanation]] ]; }; ipMaster _ Interpress.Open[fileName: fullName, log: LogIt ! IPInterpreter.Error => { -- raised if the file is non-existant Feedback.PutF[router, oneLiner, $Complaint, "%g failed: %g for %g", [rope[opRope]], [rope[explanation]], [rope[fullName]] ]; GOTO Quit; }; FS.Error => { Feedback.PutF[router, oneLiner, $Complaint, "%g failed: %g for %g", [rope[opRope]], [rope[error.explanation]], [rope[fullName]] ]; GOTO Quit; }; PFS.Error => { -- yuck: maybe Interpress.Open shouldn't raise either FS or PFS errors! Feedback.PutF[router, oneLiner, $Complaint, "%g failed: %g for %g", [rope[opRope]], [rope[error.explanation]], [rope[fullName]] ]; GOTO Quit; }; IPMaster.Error => { -- ErrorDesc: TYPE = RECORD[code: ATOM, explanation: ROPE] Feedback.PutF[router, oneLiner, $Complaint, "%g failed: %g for %g", [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.PutF[router, oneLiner, $Complaint, "%g failed: %g for %g", [rope[opRope]], [rope[error.explanation]], [rope[fullName]] ]; GOTO Quit; }; IO.Error, IO.EndOfStream => { Feedback.PutF[router, oneLiner, $Complaint, "%g failed: IO Stream Error for %g", [rope[opRope]], [rope[fullName]] ]; GOTO Quit; }; ]; IF ipMaster.pages=0 THEN { Feedback.PutF[router, oneLiner, $Complaint, "%g failed: zero pages in %g", [rope[opRope]], [rope[fullName]] ]; GOTO Quit; }; EXITS Quit => success _ FALSE; }; END. ÂGGFileOpsImpl.mesa Contents: Routines that manipulate file names or open and close files. Copyright Ó 1986, 1988, 1989, 1990 by Xerox Corporation. All rights reserved. Pier, July 3, 1991 5:55 pm PDT Bier, March 10, 1990 5:34:06 pm PST Doug Wyatt, February 21, 1990 5:43 pm PST Generic File Name Operations code copied from CommandTool.OtherCommandsImpl.mesa Convenience File Name Operations for Gargoyle Use Generic File Opening Operations �ÊŸ– "cedar" style•NewlineDelimiter ˜Icodešœ™šœG™GKšœN™NK™K™#K™)—K™šÏk ˜ Jšœ$�œ!�œ�œ˜{—K˜šÏn œ�œ�˜Kš�œ�œ�œ�œ˜hKš�œ �˜—˜Kšœ �œ˜*—K˜K™šžœ� œ+�œ�œ�œ�œ �œ�œ�œ�œ�œ �œ�œ�œ�œ˜ùKšœ�œ˜Kšœ�œ˜KšœM˜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[]]]š�œ�œ �œƒ˜˜Kš�œ˜ K˜Kšœ˜—Kš�œ�œ �œ�œ˜K–9[base: ROPE, start: INT _ 0, len: INT _ 2147483647]šœO˜Oš �œ �œ�œ�œ�œ �œ�˜Rš�œ%�œ�œ˜4Kšœ �œ˜Kš�œ�œ �œ—˜¬Kš�œ˜K˜—Kš�œ˜—Kš�œ�œ0˜GKšœ3˜3K˜K˜—š ž œ�œ�œ �œ�œ�œ˜CK™3Kšœ�œ˜š�œ�œ˜!Kšœ6˜6KšœÏc,œ˜Nš�œ˜Kš�œ�œ9˜DKš�œ�œ;˜F—K˜—Kš�œ˜K˜K˜—š žœ�œ�œ�œ�œ�œ˜Bš�œ�˜Jšœ�œ˜Jš�œ�œ˜—Jšœ˜—š žœ�œ�œ�œ�œ�œ˜]Jš œ �œ�œ�œ�œ ˜+Jšœ Ÿœ�œ,˜BJšœ˜—J˜K™1šžœ�œ�œ�œ�œ�œ�œ�œ �œ�œ˜§KšœŸœ:�œ1˜‡K˜K˜—šžœ�œ�œ�œ�œ �œ�œ�œ�œ�œ �œ�œ�œ�œ˜ÞKšœd�œD˜¬K˜K˜—šžœ�œ�œ�œ�œ�œ�œ�œ �œ�œ˜§KšœŸœB�œ;˜™K˜—K˜K™šžœ�œ�œ�œ$�œ�œ(� œ˜¡šžœ˜KšœV˜VK˜—K˜šœ;˜;šœŸ%˜>Kšœ}˜}Kš�œ˜ Kšœ˜—š�œ ˜ Kšœƒ˜ƒKš�œ˜ Kšœ˜—š�œ ŸG˜VKšœƒ˜ƒKš�œ˜ Kšœ˜—šœŸ:˜NKšœƒ˜ƒKš�œ˜ KšœŸ"˜%—šœŸ;˜MKšœƒ˜ƒKš�œ˜ Kšœ˜—š�œ�œ˜Kšœt˜tKš�œ˜ Kšœ˜—Kšœ˜—š�œ�œ˜Kšœn˜nKš�œ˜ Kšœ˜—š�˜Kšœ�œ˜—K˜K˜—Kš�œ˜K˜—…—àA