DecodeVersionFromNFSName:
PUBLIC
PROC [name:
ROPE, checkCase:
BOOL]
RETURNS [nameWithoutVersion:
ROPE, version: Version, caseOK:
BOOL] ~ {
nameLen, bangPos: INT;
versionNumber: CARD;
versionNumberRope: ROPE;
nameWithoutVersion ← name;
version ← FSBackdoor.noVersion;
caseOK ← FALSE;
nameLen ← Rope.InlineLength[name];
IF Rope.IsPrefix[SunNFSFSRemoteFile.caseFileNamePrefix, name, FALSE] THEN RETURN; -- accelerator
bangPos ← Rope.FindBackward[name, versionPartLeftBracket];
IF bangPos < 0 THEN bangPos ← nameLen;
nameWithoutVersion ← Rope.Flatten[name, 0, bangPos];
IF checkCase
THEN
{
caseOK ← TRUE;
FOR i:
INT
IN [0 .. bangPos)
DO
c: CHAR ~ Rope.InlineFetch[nameWithoutVersion, i];
IF (c >= 'A) AND (c <= 'Z) THEN { caseOK ← FALSE; EXIT };
ENDLOOP;
};
IF bangPos > (nameLen-versionPartBracketsLen) THEN RETURN;
IF Rope.InlineFetch[name, nameLen-1] = versionPartRightBracket
THEN versionNumberRope ← Rope.Substr[name, bangPos+versionPartLeftBracketLen, nameLen-bangPos-versionPartBracketsLen]
ELSE versionNumberRope ← Rope.Substr[name, bangPos+versionPartLeftBracketLen];
versionNumber ← Convert.CardFromRope[versionNumberRope, 10
! Convert.Error => {versionNumber ← CARDINAL.LAST; CONTINUE }];
version ←
SELECT versionNumber
FROM
0 => FSBackdoor.noVersion,
>= CARDINAL.LAST => FSBackdoor.noVersion,
ENDCASE => [CARDINAL[versionNumber]];
};
EncodeVersionInNFSName:
PUBLIC
PROC [name:
ROPE, version: Version]
RETURNS [nameWithVersion:
ROPE] ~ {
versionNumber: CARDINAL ← version;
bangPos: INT ← Rope.FindBackward[name, ".~"];
IF bangPos >= 0 THEN name ← Rope.Substr[name, 0, bangPos];
nameWithVersion ← Rope.Cat[ name, ".~", Convert.RopeFromCard[versionNumber, 10, FALSE], "~" ];
};