<<>> <> <> <> <> <> <> <> <> <> <<>> DIRECTORY Atom, BasicTime USING[FromNSTime, GMT, nullGMT, OutOfRange, ToNSTime], CCTypes USING[CCError, CCErrorCase], CirioDeltaFace USING[DebuggeeNameToDebuggerName, TargetVersionMapName], Commander, Convert, MobDefs, MorePfsNames, IO, PFS, PFSNames, Rope, RopeParts, RopeSequence, SimpleFeedback USING[PutF], SourceFileOpsExtras USING [FullOpenSource, Position], SymTab, SystemInterface USING[CirioFileInfo], VersionMap, VersionMap2, VersionMap2Binding; SystemInterfaceImpl: CEDAR MONITOR LOCKS set USING set: FileSet IMPORTS Atom, BasicTime, CCTypes, CirioDeltaFace, Commander, Convert, IO, MorePfsNames, PFS, PFSNames, Rope, RopeParts, RopeSequence, SimpleFeedback, SourceFileOpsExtras, SymTab, VersionMap2, VersionMap2Binding EXPORTS SystemInterface = BEGIN OPEN IO, MPN:MorePfsNames, Rope, RP:RopeParts, RS:RopeSequence, VM2:VersionMap2, VM2Binding:VersionMap2Binding; CCE: ERROR[case: CCTypes.CCErrorCase, msg: Rope.ROPE _ NIL] _ CCTypes.CCError; <> PATH: TYPE ~ PFSNames.PATH; PathList: TYPE ~ LIST OF PATH; Component: TYPE ~ PFSNames.Component; ROPE: TYPE ~ Rope.ROPE; RopeList: TYPE ~ LIST OF ROPE; RopePart: TYPE ~ RP.RopePart; RopeSeq: TYPE ~ RS.RopeSeq; <<>> <> ShowReport: PUBLIC SIGNAL[msgText: ROPE, priority: ATOM] = CODE; <> << $urgent, $normal, $debug>> <> ShowSource: PUBLIC PROC [desc: ROPE, pos: SourceFileOpsExtras.Position, feedBack: STREAM _ NIL] = BEGIN SourceFileOpsExtras.FullOpenSource[desc, pos, feedBack]; END; <> <> <<>> <sub-dir>...>rootName.>> <<>> DirectorySeparatorChar: CHAR = '>; DirectorySeparatorString: ROPE = ">"; <<>> <<>> <> <> <> <> <> <> <> <> <> <> <<>> <<>> <> <<{IO.PutF[reports, "selection not in a mesa file, aborting\N"]; RETURN[NIL]};>> <<>> <> <<(THIS should really be in symbol finding)>> <<(we don't check any version stamps, we should)>> <> <> <> <> <> <> <<>> <> < CONTINUE];>> <> <> <> < CONTINUE]};>> <> <<{IO.PutF[reports, "coresponding c file must be in same directory as selected mesa file, aborting\N"]; RETURN[NIL]};>> <> <<>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<[fullMesaName, positionsInMesaName, dirOmittedInMesaName] _ FS.ExpandName[mesaFileName];>> <> <> <<>> <> <> <> <> <<>> <> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <> <> <> <<>> <> <<[dirPath, rootName, ext] _ DisassembleUnixFileName[dotOFileName];>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <<>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <> <> <> <> <> <> <> <> <> <'s.>> <> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <> <> <> <> <<>> <> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <> < lenFileName THEN RETURN [fileName];>> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <<>> FileSet: TYPE = REF FileSetBody; FileSetBody: PUBLIC TYPE = MONITORED RECORD[ files: LIST OF CirioFile, nOpenStreams: CARD, openInactiveStreams: LIST OF REF FileStreamInfo, lastOpenInactiveStream: LIST OF REF FileStreamInfo]; CirioFile: TYPE = REF CirioFileBody; <> CirioFileBody: PUBLIC TYPE = RECORD[ fileSet: FileSet, name: PATH, infoValid: BOOLEAN, info: SystemInterface.CirioFileInfo, streams: LIST OF REF FileStreamInfo]; FileStreamInfo: TYPE = RECORD[ file: CirioFile, active: BOOLEAN, stream: IO.STREAM, openFile: PFS.OpenFile, fileInfo: SystemInterface.CirioFileInfo]; <> <> NominalMaxOpenStreams: CARD _ 10; <> CreateFileSet: PUBLIC PROC RETURNS[FileSet] = {RETURN[NEW[FileSetBody_[ , NIL, 0, NIL, NIL]]]}; CloseFileSet: PUBLIC ENTRY PROC[set: FileSet] = BEGIN ENABLE UNWIND => NULL; FOR fl: LIST OF CirioFile _ set.files, fl.rest WHILE fl # NIL DO FOR sl: LIST OF REF FileStreamInfo _ fl.first.streams, sl.rest WHILE sl # NIL DO IF sl.first.stream # NIL THEN {IO.Close[sl.first.stream]; sl.first.stream _ NIL}; ENDLOOP; ENDLOOP; END; GetCirioFileFromDebuggee: PUBLIC PROC[set: FileSet, name: PATH, debuggee: Rope.ROPE, uniqueID: PFS.UniqueID _ PFS.nullUniqueID] RETURNS[cf: CirioFile] ~ { localName: PATH ~ DebuggeeUnixNameToDebuggerCedarName[name, debuggee]; cf _ GetCirioFile[set, localName, uniqueID]; IF cf=NIL THEN ShowReport[IO.PutFR["Local name (%g) for remote name (%g, on %g, created %g) doesn't work", [rope[PFS.RopeFromPath[localName]]], [rope[PFS.RopeFromPath[name]]], [rope[IF debuggee#NIL THEN debuggee ELSE "self"]], [rope[FmtUniqueID[uniqueID]]] ], $urgent]; RETURN}; <> GetCirioFile: PUBLIC ENTRY PROC[set: FileSet, name: PATH, uniqueID: PFS.UniqueID _ PFS.nullUniqueID] RETURNS[CirioFile] = { ENABLE UNWIND => NULL; RETURN InnerGetCirioFile[set, name, uniqueID]}; InnerGetCirioFile: INTERNAL PROC[set: FileSet, name: PATH, uniqueID: PFS.UniqueID] RETURNS[CirioFile] = { noDate: BOOL ~ uniqueID=PFS.nullUniqueID; FOR fl: LIST OF CirioFile _ set.files, fl.rest WHILE fl # NIL DO IF name.Equal[fl.first.name] AND (noDate OR uniqueID=fl.first.info.uniqueID) THEN RETURN[fl.first]; ENDLOOP; <> { fileToOpen: PATH _ name; file: CirioFile _ NEW[CirioFileBody_[set, fileToOpen, TRUE, [uniqueID, 0, fileToOpen], NIL]]; [bytes: file.info.bytes, uniqueID: file.info.uniqueID] _ PFS.FileInfo[file.name, uniqueID !PFS.Error => { asRope: ROPE ~ PFS.RopeFromPath[file.name]; GOTO DontExist}]; set.files _ CONS[file, set.files]; RETURN[file]; EXITS DontExist => RETURN [NIL]; }; }; <<>> <> <> GenCirioFilesForInfo: PUBLIC PROC[set: FileSet, pattern: PATH, for: PROC[SystemInterface.CirioFileInfo] RETURNS[thisIsIt: BOOLEAN]] RETURNS[found: CirioFile] = BEGIN ENABLE UNWIND => NULL; result: CirioFile _ NIL; local: PROC [ fullFName, attachedTo: PATH, uniqueID: PFS.UniqueID, bytes: INT, mutability: PFS.Mutability, fileType: PFS.FileType ] RETURNS [continue: BOOL] = <<(a PFS.InfoProc)>> BEGIN stop: BOOLEAN _ for[[uniqueID, bytes, fullFName]]; IF stop THEN result _ GetCirioFile[set, fullFName, uniqueID]; RETURN[NOT stop]; END; PFS.EnumerateForInfo[pattern, local ! PFS.Error => CONTINUE]; RETURN[result]; END; <<>> warnOnVmPfsErr: BOOL _ FALSE; verboseGenVm: BOOL _ FALSE; <> <> GenVersionMapFilesForInfo: PUBLIC PROC [set: FileSet, map: ATOM, versionStamp: MobDefs.VersionStamp, stems: PathList, suffixes: RopeList, testName: BOOL, for: PROC[SystemInterface.CirioFileInfo] RETURNS[thisIsIt: BOOLEAN], wantedUniqueID: PFS.UniqueID _ PFS.nullUniqueID] RETURNS[found: CirioFile _ NIL] = { targetMap: ATOM ~ CirioDeltaFace.TargetVersionMapName[map]; vmap: VM2.Map ~ VM2Binding.GetMap[Atom.GetPName[targetMap]]; noDate: BOOL _ wantedUniqueID=PFS.nullUniqueID; GenerateNames: PROC [Test: PROC [ROPE] RETURNS [BOOL]] RETURNS [BOOL] ~ { FOR steml: PathList _ stems, steml.rest WHILE steml#NIL DO FOR sufl: RopeList _ suffixes, sufl.rest WHILE sufl#NIL DO IF Test[ Rope.Concat[ PFS.RopeFromPath[steml.first], sufl.first] ] THEN RETURN [TRUE]; ENDLOOP; ENDLOOP; RETURN [FALSE]}; TryName: PROC [short: ROPE] RETURNS [BOOL] ~ { triedDirs: SymTab.Ref ~ SymTab.Create[case: TRUE]; TryTuple: PROC [t: VM2.VersionTuple] RETURNS [BOOL] ~ { fullRope: ROPE ~ PFS.RopeFromPath[t.name]; foundStamp: VersionMap.VersionStamp ~ t.stamp; uniqueID: PFS.UniqueID _ t.created; full: PFSNames.PATH _ t.name; directory, verless: PFSNames.PATH; IF verboseGenVm THEN ShowReport[IO.PutFR["\tvm: %g\n", [rope[fullRope]] ], $urgent]; directory _ full.Directory; verless _ full.StripVersionNumber; IF noDate THEN { {bytes: INT; [fullFName: full, bytes: bytes, uniqueID: uniqueID] _ PFS.FileInfo[full, wantedUniqueID !PFS.Error => { IF warnOnVmPfsErr THEN ShowReport[IO.PutFR["PFS.FileInfo[%g (from version map)] => PFS.Error[%g, %g]", [rope[fullRope]], [atom[error.code]], [rope[error.explanation]] ], $urgent]; uniqueID _ PFS.nullUniqueID; GOTO NotMe}]; IF for[[uniqueID, bytes, full]] THEN found _ GetCirioFile[set, full, uniqueID]; EXITS NotMe => found _ NIL}; IF found=NIL AND triedDirs.Insert[PFS.RopeFromPath[directory], $T] THEN { highestFull: PATH; highestCreated: PFS.UniqueID; FilteringFor: PROC[cfi: SystemInterface.CirioFileInfo] RETURNS[thisIsIt: BOOLEAN] ~ { IF cfi.uniqueID=highestCreated AND cfi.fullName.Equal[highestFull, FALSE] THEN RETURN [FALSE]; RETURN for[cfi]}; {bytes: INT; [fullFName: highestFull, bytes: bytes, uniqueID: highestCreated] _ PFS.FileInfo[verless !PFS.Error => { IF warnOnVmPfsErr THEN ShowReport[IO.PutFR["PFS.FileInfo[%g (from version map)] => PFS.Error[%g, %g]", [rope[PFS.RopeFromPath[verless]]], [atom[error.code]], [rope[error.explanation]] ], $urgent]; GOTO NotHere}]; IF highestCreated#uniqueID AND for[[highestCreated, bytes, highestFull]] THEN found _ GetCirioFile[set, highestFull, highestCreated]; EXITS NotHere => short _ short}; IF found=NIL THEN found _ GenCirioFilesForInfo[set, verless.SetVersionNumber[[PFSNames.VersionKind.all, 0]], FilteringFor]}; } ELSE {bytes: INT; [fullFName: full, bytes: bytes, uniqueID: uniqueID] _ PFS.FileInfo[verless, wantedUniqueID !PFS.Error => { IF warnOnVmPfsErr THEN ShowReport[IO.PutFR["PFS.FileInfo[%g (from version map), %g] => PFS.Error[%g, %g]", [rope[PFS.RopeFromPath[verless]]], IF wantedUniqueID.egmt.time=BasicTime.nullGMT THEN [rope["nullGMT"]] ELSE [time[wantedUniqueID.egmt.time]], [atom[error.code]], [rope[error.explanation]] ], $urgent]; GOTO None}]; IF for[[uniqueID, bytes, full]] THEN found _ GetCirioFile[set, full, uniqueID]; EXITS None => NULL}; RETURN [found#NIL]}; pat: VM2.VersionTuple ~ [VM2.ShortNameToPattern[short].name, wantedUniqueID, versionStamp]; RETURN [VM2.ScanMatches[vmap, TryTuple, FALSE, pat].found]}; IF testName THEN [] _ GenerateNames[TryName] ELSE [] _ TryName["*"]; RETURN}; GetNameOfFile: PUBLIC PROC[file: CirioFile] RETURNS[PATH] = BEGIN inner: ENTRY PROC[set: FileSet] RETURNS[PATH] = {ENABLE UNWIND => NULL; RETURN[file.name]}; IF file = NIL THEN RETURN[NIL] ELSE RETURN[inner[file.fileSet]]; END; GetFileInfo: PUBLIC PROC[file: CirioFile] RETURNS[SystemInterface.CirioFileInfo] = BEGIN inner: ENTRY PROC[set: FileSet] RETURNS[SystemInterface.CirioFileInfo] = BEGIN ENABLE UNWIND => NULL; IF NOT file.infoValid THEN ERROR<>; RETURN[file.info]; END; RETURN[inner[file.fileSet]] END; GetStreamForFile: PUBLIC PROC[file: CirioFile] RETURNS[IO.STREAM] = { IF file=NIL THEN RETURN[NIL] ELSE RETURN EnterGetStreamForFile[file.fileSet, file]}; EnterGetStreamForFile: ENTRY PROC[set: FileSet, file: CirioFile] RETURNS[IO.STREAM] = { ENABLE UNWIND => NULL; RETURN InnerGetStreamForFile[set, file]}; InnerGetStreamForFile: INTERNAL PROC[set: FileSet, file: CirioFile] RETURNS[IO.STREAM] = { IF NOT file.infoValid THEN ERROR<>; FOR sl: LIST OF REF FileStreamInfo _ file.streams, sl.rest WHILE sl # NIL DO IF NOT sl.first.active THEN BEGIN sl.first.active _ TRUE; IF sl.first.stream # NIL THEN BEGIN -- remove from the open but inactive list, and reset position set: FileSet _ file.fileSet; stream: REF FileStreamInfo _ sl.first; removed: BOOLEAN _ FALSE; info: SystemInterface.CirioFileInfo; IF set.openInactiveStreams = NIL THEN ERROR; IF set.openInactiveStreams.first = stream THEN {set.openInactiveStreams _ set.openInactiveStreams.rest; removed _ TRUE} ELSE FOR sl: LIST OF REF FileStreamInfo _ set.openInactiveStreams, sl.rest WHILE sl.rest # NIL DO IF sl.rest.first = stream THEN {sl.rest _ sl.rest.rest; removed _ TRUE; EXIT}; ENDLOOP; IF NOT removed THEN ERROR; IF set.lastOpenInactiveStream.first = stream THEN BEGIN -- ugh ... fixup IF set.openInactiveStreams = NIL THEN set.lastOpenInactiveStream _ NIL ELSE FOR sl: LIST OF REF FileStreamInfo _ set.openInactiveStreams, sl.rest DO IF sl.rest = NIL THEN {set.lastOpenInactiveStream _ sl; EXIT}; ENDLOOP; END; <> [bytes: info.bytes, uniqueID: info.uniqueID] _ PFS.GetInfo[stream.openFile]; IF info.bytes # stream.fileInfo.bytes OR info.uniqueID # stream.fileInfo.uniqueID THEN -- file has changed ERROR PFS.Error[[environment, $ImmutableFileChanged, IO.PutFR["The CirioFile for %g of %g len %g has changed", [rope[PFS.RopeFromPath[file.name]]], [rope[FmtUniqueID[file.info.uniqueID]]], [integer[file.info.bytes]] ]]] <>; IO.SetIndex[stream.stream, 0]; RETURN[stream.stream]; END ELSE -- we have to open the stream BEGIN sl.first.stream _ PFS.StreamOpen[file.name, read, file.info.uniqueID]; sl.first.openFile _ PFS.OpenFileFromStream[sl.first.stream]; sl.first.fileInfo _ file.info; <<[bytes: sl.first.fileInfo.bytes, uniqueID: sl.first.fileInfo.uniqueID] _ PFS.GetInfo[sl.first.openFile]; file.info _ sl.first.fileInfo; -- update the file info>> file.fileSet.nOpenStreams _ file.fileSet.nOpenStreams+1; CheckNOpenStreamsP[file.fileSet]; RETURN[sl.first.stream]; END; END; ENDLOOP; <> BEGIN stream: IO.STREAM _ PFS.StreamOpen[file.name, read, file.info.uniqueID]; openFile: PFS.OpenFile _ PFS.OpenFileFromStream[stream]; streamInfo: REF FileStreamInfo _ NEW[FileStreamInfo_[ file, TRUE, stream, openFile, file.info]]; <<[bytes: streamInfo.fileInfo.bytes, uniqueID: streamInfo.fileInfo.uniqueID] _ PFS.GetInfo[openFile]; file.info _ streamInfo.fileInfo; -- update the file info>> file.streams _ CONS[streamInfo, file.streams]; file.fileSet.nOpenStreams _ file.fileSet.nOpenStreams+1; CheckNOpenStreamsP[file.fileSet]; RETURN[file.streams.first.stream]; END; }; ReleaseStreamForFile: PUBLIC PROC[file: CirioFile, stream: IO.STREAM] = BEGIN inner: ENTRY PROC[set: FileSet] = BEGIN ENABLE UNWIND => NULL; FOR sl: LIST OF REF FileStreamInfo _ file.streams, sl.rest WHILE sl # NIL DO IF sl.first.stream = stream THEN BEGIN cell: LIST OF REF FileStreamInfo _ LIST[sl.first]; cell.first.active _ FALSE; IF file.fileSet.openInactiveStreams = NIL THEN file.fileSet.openInactiveStreams _ cell ELSE file.fileSet.lastOpenInactiveStream.rest _ cell; file.fileSet.lastOpenInactiveStream _ cell; CheckNOpenStreamsP[file.fileSet]; RETURN; END; ENDLOOP; ERROR; END; inner[file.fileSet]; END; CheckNOpenStreamsP: PROC[set: FileSet] = BEGIN IF set.nOpenStreams > NominalMaxOpenStreams AND set.openInactiveStreams # NIL THEN BEGIN toClose: REF FileStreamInfo _ set.openInactiveStreams.first; set.openInactiveStreams _ set.openInactiveStreams.rest; IO.Close[toClose.stream]; toClose.stream _ NIL; IF toClose.active THEN ERROR; set.nOpenStreams _ set.nOpenStreams - 1; END; END; <<>> <> <<>> BadDotONameSyntax: ERROR = CODE; <> <> <> <> <> <> <> <> <> <> < GOTO fails; cirioPrefix: PATH _ PFSNames.EmptyPath; cirioRemainingFileName: PATH _ PFSNames.EmptyPath; volume: PATH _ PFSNames.EmptyPath; name1: PATH _ PFSNames.EmptyPath; remainingPath: PATH _ PFSNames.EmptyPath; machineDependentSubdir: PATH _ PFSNames.EmptyPath; stem: RopePart; secondaryExtension: RopePart; extension: RopePart; version: PFSNames.Version; fileNameSeq: RopeSeq _ NIL; tentativeRemainingPath: LIST OF Component _ NIL; exit: BOOLEAN _ FALSE; <> curPart: Component _ unixFileName.Fetch[1]; curPartRope: ROPE _ curPart.ComponentRope; nextPart: INT _ 1; IF Rope.Equal[curPartRope, "tmp_mnt", FALSE] THEN { curPart _ unixFileName.Fetch[2]; curPartRope _ curPart.ComponentRope; IF Rope.Equal[curPartRope, "net", FALSE] THEN { nextPart _ 3; volume _ PFSNames.ConstructName[LIST[unixFileName.Fetch[0], unixFileName.Fetch[1], curPart], FALSE, TRUE]; }; } ELSE IF curPartRope.Equal["volume", FALSE] OR curPartRope.Equal["net", FALSE] OR curPartRope.Equal["pseudo", FALSE] THEN { nextPart _ 2; volume _ PFSNames.ConstructName[LIST[unixFileName.Fetch[0], curPart], FALSE, TRUE]; }; IF volume = PFSNames.EmptyPath THEN volume _ PFSNames.ConstructName[LIST[unixFileName.Fetch[0]], FALSE, TRUE]; IF PFS.RopeFromPath[volume].Substr[0,3].Equal["-ux"] THEN volume _ PFS.PathFromRope[PFS.RopeFromPath[volume].Replace[0, 3, ""]]; <> IF unixFileName.ComponentCount # 3 OR volume.ComponentCount = 1 THEN { curPart _ unixFileName.Fetch[nextPart]; name1 _ PFSNames.ConstructName[LIST[curPart], FALSE, TRUE]} ELSE nextPart _ nextPart - 1; <> nextPart _ nextPart + 1; FOR part: INT _ nextPart, part+1 UNTIL part = unixFileName.ComponentCount-1 OR exit = TRUE DO nextPart _ part+1; curPart _ unixFileName.Fetch[part]; IF CirioDeltaFace.IsMachineDependentSubdirectory[curPart] THEN { exit _ TRUE; machineDependentSubdir _ PFSNames.ConstructName[LIST[curPart], FALSE, TRUE]} ELSE tentativeRemainingPath _ CONS[curPart, tentativeRemainingPath]; ENDLOOP; remainingPath _ PFSNames.ConstructName[tentativeRemainingPath, FALSE, TRUE, TRUE]; <> curPart _ unixFileName.Fetch[nextPart]; version _ curPart.version; curPartRope _ curPart.ComponentRope; { fnPart: RopePart _ RS.PartFromRope[curPartRope]; fileNameSeq _ RS.ParsePartToSeq[fnPart, '.]; SELECT fileNameSeq.ComponentCount FROM 1 => stem _ fileNameSeq.Fetch[0]; 2 => { stem _ fileNameSeq.Fetch[0]; extension _ fileNameSeq.Fetch[1]; }; 3 => { stem _ fileNameSeq.Fetch[0]; secondaryExtension _ fileNameSeq.Fetch[1]; extension _ fileNameSeq.Fetch[2]; }; ENDCASE => { stem _ fileNameSeq.Fetch[0]; secondaryExtension _ fileNameSeq.Fetch[1]; extension _ fileNameSeq.Fetch[2]; }; }; cirioPrefix _ volume.Cat[name1]; cirioRemainingFileName _ PFSNames.EmptyPath; cirioRemainingFileName _ remainingPath.Cat[machineDependentSubdir]; cirioRemainingFileName _ cirioRemainingFileName.Cat[ PFS.PathFromRope[RS.ConstructSeq[LIST[stem,secondaryExtension,extension]].UnparseSeqToPart['.].RopeFromPart]]; <> curPartRope _ PFS.RopeFromPath[cirioRemainingFileName]; IF curPartRope.Fetch[curPartRope.Length-1] = ': THEN cirioRemainingFileName _ PFS.PathFromRope[curPartRope.Substr[0, curPartRope.Length - 1]]; cirioRemainingFileName _ cirioRemainingFileName.SetVersionNumber[version]; RETURN[[ cirioPrefix: cirioPrefix, cirioRemainingFileName: cirioRemainingFileName, volume: volume, name1: name1, remainingPath: remainingPath, machineDependentSubdir: machineDependentSubdir, stem: stem, secondaryExtension: secondaryExtension, extension: extension, version: version ]]; EXITS fails => BadDotONameSyntax[]; END; GetLocalFileName: PROC [fileName: PFSNames.PATH, serverName: ROPE _ NIL] RETURNS [PFSNames.PATH] ~ { unixName: FactoredUnixFileName _ []; ourPrefix: PATH; <> IF serverName = NIL OR serverName.Equal["sameWorld"] THEN RETURN [fileName]; <> unixName _ FactorUnixFileName[fileName ! BadDotONameSyntax => BEGIN ShowReport[Rope.Cat["Unable to factor unix name ", PFS.RopeFromPath[fileName]], $urgent]; unixName.cirioPrefix _ NIL; CONTINUE; END;]; IF debugNaming THEN SimpleFeedback.PutF[$CirioSystemInterface, oneLiner, $Naming, "Factor[%g, %g] => %g", [rope[PFS.RopeFromPath[fileName]]], [rope[IF serverName=NIL THEN "NIL" ELSE Convert.RopeFromRope[serverName]]], [rope[FmtFufn[unixName]]] ]; IF unixName.cirioPrefix = NIL THEN RETURN[fileName]; <> ourPrefix _ CirioDeltaFace.GetOurPrefixForUnixPrefix[unixName.volume, unixName.name1, serverName, "ux"]; IF debugNaming THEN SimpleFeedback.PutF[$CirioSystemInterface, oneLiner, $Naming, "GetOur... => %g", [rope[PFS.RopeFromPath[ourPrefix]]] ]; RETURN[ourPrefix.Cat[unixName.cirioRemainingFileName]]; }; FmtFufn: PROC [fufn: FactoredUnixFileName] RETURNS [ROPE] ~ { buf: IO.STREAM ~ IO.ROS[]; buf.PutF["[cp:%g, crfn:%g; vol:%g, n1:%g, ", [rope[PFS.RopeFromPath[fufn.cirioPrefix]]], [rope[PFS.RopeFromPath[fufn.cirioRemainingFileName]]], [rope[PFS.RopeFromPath[fufn.volume]]], [rope[PFS.RopeFromPath[fufn.name1]]] ]; buf.PutF["rp:%g, mds:%g, stem:%g, se:%g, e:%g, v:", [rope[PFS.RopeFromPath[fufn.remainingPath]]], [rope[PFS.RopeFromPath[fufn.machineDependentSubdir]]], [rope[RS.RopeFromPart[fufn.stem]]], [rope[RS.RopeFromPart[fufn.secondaryExtension]]], [rope[RS.RopeFromPart[fufn.extension]]] ]; SELECT fufn.version.versionKind FROM numeric => buf.Put[ [cardinal[fufn.version.version]] ]; none => buf.PutRope["none"]; lowest => buf.PutRope["lowest"]; highest => buf.PutRope["highest"]; next => buf.PutRope["next"]; all => buf.PutRope["all"]; ENDCASE => buf.PutRope["?"]; buf.PutChar[']]; RETURN buf.RopeFromROS[]}; >> DebuggeeUnixNameToDebuggerCedarName: PUBLIC PROC [unixName: PATH, debuggee: ROPE] RETURNS [cedar: PATH] ~ { lc: Component; c0: ROPE _ "-ux"; cedar _ unixName; lc _ cedar.ShortName[]; IF NOT cedar.Fetch[0].ComponentRope.IsEmpty THEN ShowReport[IO.PutFR["Given unix name (%g) on debuggee (%g) with non-empty 0'th component", [rope[PFS.RopeFromPath[unixName]]], [rope[debuggee]] ], $normal] ELSE IF lc.version.versionKind # none THEN ShowReport[IO.PutFR["Given unix name (%g) on debuggee (%g) with non-empty version", [rope[PFS.RopeFromPath[unixName]]], [rope[debuggee]] ], $normal] ELSE { rs: RopeSeq ~ RS.ParsePartToSeq[MPN.ComponentName[lc], '.]; n: NAT ~ RS.Length[rs]; le: RopePart ~ rs.Fetch[n-1]; lel: INT ~ le.Length[]; IF lel>2 AND le.Fetch[0]='~ AND le.Fetch[lel-1]='~ THEN { ver: CARD ~ Convert.CardFromRope[le.Substr[start: 1, len: lel-2].ToRope !Convert.Error => GOTO NotNum]; IF ver > CARDINAL.LAST THEN ShowReport[IO.PutFR["Can't naturalize huge version of unix name (%g) from debuggee (%g) - left in -ux: syntax", [rope[PFS.RopeFromPath[unixName]]], [rope[debuggee]] ], $urgent] ELSE { lc.name.len _ lc.name.len - (lel+1); lc.version _ [numeric, ver]; cedar _ cedar.ReplaceShortName[lc]; c0 _ "-vux"}; EXITS NotNum => c0 _ c0}; cedar _ cedar.ReplaceComponent[0, [name: [c0, 0, c0.Length]]]; }; IF debuggee#NIL AND NOT debuggee.Equal["SameWorld", FALSE] THEN { Warn: PROC [r: ROPE] ~ {ShowReport[r, $urgent]}; local: PATH ~ CirioDeltaFace.DebuggeeNameToDebuggerName[cedar, debuggee, Warn]; IF debugNaming THEN SimpleFeedback.PutF[$SystemInterfaceImpl, oneLiner, $Naming, "Localize[%g, %g] => %g", [rope[debuggee]], [rope[PFS.RopeFromPath[cedar]]], [rope[PFS.RopeFromPath[local]]] ]; cedar _ local}; RETURN}; debugNaming: BOOL _ FALSE; FmtUniqueID: PUBLIC PROC [uid: PFS.UniqueID] RETURNS [ROPE] ~ { time: ROPE _ "error formatting time"; IF uid.egmt.time = BasicTime.nullGMT THEN time _ "unspecified" ELSE time _ Convert.RopeFromTime[uid.egmt.time, years, seconds, FALSE, FALSE !Convert.Error => CONTINUE]; IF uid.egmt.usecs#0 THEN time _ IO.PutFR["%g plus %gus", [rope[time]], [cardinal[uid.egmt.usecs]] ]; IF uid.host # [0, 0] THEN time _ IO.PutFR["%g host [%xH, %xH]", [rope[time]], [cardinal[uid.host.a]], [cardinal[uid.host.b]] ]; RETURN [time]}; VersionStampToUniqueID: PUBLIC PROC [vs: MobDefs.VersionStamp] RETURNS [uid: PFS.UniqueID] ~ { IF vs[1]#0 THEN CCE[cirioError, IO.PutFR["MobDefs.VersionStamp[%xH, %xH] can't be converted to a create date", [cardinal[vs[0]]], [cardinal[vs[1]]] ]]; uid _ [egmt: [time: BasicTime.FromNSTime[vs[0] ! BasicTime.OutOfRange => CCE[cirioError, IO.PutFR["MobDefs.VersionStamp[%xH, 0] doesn't encode a valid create date", [cardinal[vs[0]]] ]] ]]]; RETURN}; UniqueIDToVersionStamp: PUBLIC PROC [uid: PFS.UniqueID] RETURNS [vs: MobDefs.VersionStamp] ~ { IF uid.egmt.usecs # 0 OR uid.host # [0, 0] THEN ERROR CCE[cirioError, IO.PutFR["PFS.UniqueID %g can't be converted to a MobDefs.VersionStamp", [rope[FmtUniqueID[uid]]] ]]; vs _ [BasicTime.ToNSTime[uid.egmt.time], 0]; RETURN}; <> Verbosify: Commander.CommandProc = {warnOnVmPfsErr _ verboseGenVm _ TRUE}; Tersify: Commander.CommandProc = {warnOnVmPfsErr _ verboseGenVm _ FALSE}; Commander.Register["Cirio.verboseScanVersionMaps", Verbosify]; Commander.Register["Cirio.terseScanVersionMaps", Tersify]; END.