-- AlpFileImpl.mesa
-- Last edited by
-- Kolling on September 1, 1983 11:53 am


DIRECTORY

AlpineEnvironment
USING[AccessRights, FileID, LockFailure, LockOption, NeededAccess, OpenFileID,
OperationFailure, OwnerName, PageCount, PageRun, PropertyValuePair,
RecoveryOption, ReferencePattern, UniversalFile, UnknownType, VolOrVolGroupID],
AlpFile
USING[Handle, Object, PropertySet, RESULTPageBuffer, VALUEPageBuffer],
AlpineFile
USING[AccessFailed, LockFailed, OperationFailed, PossiblyDamaged,
StaticallyInvalid, Unknown],
AlpPrivate
USING[NoticeUnboundInstance],
AlpTransaction
USING[Handle],
File
USING[Type],
RPC
USING[CallFailed];


AlpFileImpl: CEDAR PROGRAM
IMPORTS AF: AlpineFile, AlpP: AlpPrivate, RPC
EXPORTS AlpFile =

BEGIN OPEN AlpF: AlpFile, AE: AlpineEnvironment, AlpT: AlpTransaction;


-- in addition to the errors documented for the corresponding Alpine procedures, all of the procedures defined in this interface can also error RPC.CallFailed[RPC.CallFailure].

Open: PUBLIC PROCEDURE[transHandle: AlpT.Handle, universalFile: AE.UniversalFile,
access: AE.AccessRights, lock: AE.LockOption, recoveryOption: AE.RecoveryOption,
referencePattern: AE.ReferencePattern] RETURNS[handle: AlpF.Handle,
fileID: AE.FileID] =
BEGIN
openFileID: AE.OpenFileID;
TRUSTED BEGIN [openFileID, fileID] ← transHandle.inst.file.Open[transHandle.inst.conversation,
transHandle.transID, universalFile, access, lock, recoveryOption, referencePattern
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[transHandle.inst]]; END;
handle ← NEW[AlpF.Object ← [trans: transHandle, openFileID: openFileID]];
END;

Create: PUBLIC PROCEDURE[transHandle: AlpT.Handle, volumeID: AE.VolOrVolGroupID, owner:
AE.OwnerName, initialSize: AE.PageCount, type: File.Type, recoveryOption:
AE.RecoveryOption, referencePattern: AE.ReferencePattern] RETURNS[handle:
AlpF.Handle, refUniversalFile: REF AE.UniversalFile] =
BEGIN
ENABLE RPC.CallFailed => IF why = unbound OR why = timeout
THEN AlpP.NoticeUnboundInstance[transHandle.inst];
openFileID: AE.OpenFileID;
universalFile: AE.UniversalFile;
TRUSTED BEGIN [openFileID, universalFile] ←
transHandle.inst.file.Create[transHandle.inst.conversation, transHandle.transID, volumeID,
owner, initialSize, type, recoveryOption, referencePattern]; END;
handle ← NEW[AlpF.Object ← [trans: transHandle, openFileID: openFileID]];
refUniversalFile ← NEW[AE.UniversalFile ←universalFile];
END;

Close: PUBLIC PROCEDURE[handle: AlpF.Handle] =
TRUSTED BEGIN handle.trans.inst.file.Close[handle.trans.inst.conversation, handle.openFileID
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

Delete: PUBLIC PROCEDURE[handle: AlpF.Handle] =
TRUSTED BEGIN handle.trans.inst.file.Delete[handle.trans.inst.conversation, handle.openFileID
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

ReadPages: PUBLIC UNSAFE PROCEDURE[handle: AlpF.Handle, pageRun: AE.PageRun, pageBuffer:
AlpF.RESULTPageBuffer, lock: AE.LockOption] =
TRUSTED BEGIN handle.trans.inst.file.ReadPages[handle.trans.inst.conversation,
handle.openFileID, pageRun, pageBuffer, lock
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

WritePages: PUBLIC PROCEDURE[handle: AlpF.Handle, pageRun: AE.PageRun, pageBuffer:
AlpF.VALUEPageBuffer, lock: AE.LockOption] =
TRUSTED BEGIN handle.trans.inst.file.WritePages[handle.trans.inst.conversation,
handle.openFileID, pageRun, pageBuffer, lock
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

ReadProperties: PUBLIC PROCEDURE[handle: AlpF.Handle, desiredProperties: AlpF.PropertySet,
lock: AE.LockOption] RETURNS[properties: LIST OF AE.PropertyValuePair] =
TRUSTED BEGIN RETURN[handle.trans.inst.file.ReadProperties[handle.trans.inst.conversation,
handle.openFileID, desiredProperties, lock
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]]];
END;

WriteProperties: PUBLIC PROCEDURE[handle: AlpF.Handle, properties: LIST OF
AE.PropertyValuePair, lock: AE.LockOption] =
TRUSTED BEGIN handle.trans.inst.file.WriteProperties[handle.trans.inst.conversation,
handle.openFileID, properties, lock
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

LockPages: PUBLIC PROCEDURE[handle: AlpF.Handle, pageRun: AE.PageRun, lock:
AE.LockOption] =
TRUSTED BEGIN handle.trans.inst.file.LockPages[handle.trans.inst.conversation,
handle.openFileID, pageRun, lock
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

UnlockPages: PUBLIC PROCEDURE[handle: AlpF.Handle, pageRun: AE.PageRun] =
TRUSTED BEGIN handle.trans.inst.file.UnlockPages[handle.trans.inst.conversation,
handle.openFileID, pageRun
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

GetAccessRights: PUBLIC PROCEDURE[handle: AlpF.Handle] RETURNS[access:
AE.AccessRights] =
TRUSTED BEGIN RETURN[handle.trans.inst.file.GetAccessRights[handle.trans.inst.conversation,
handle.openFileID
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]]];
END;

GetLockOption: PUBLIC PROCEDURE[handle: AlpF.Handle] RETURNS[lock: AE.LockOption] =
TRUSTED BEGIN RETURN[handle.trans.inst.file.GetLockOption[handle.trans.inst.conversation,
handle.openFileID
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]]];
END;

SetLockOption: PUBLIC PROCEDURE[handle: AlpF.Handle, lock: AE.LockOption] =
TRUSTED BEGIN handle.trans.inst.file.SetLockOption[handle.trans.inst.conversation,
handle.openFileID, lock
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

GetRecoveryOption: PUBLIC PROCEDURE[handle: AlpF.Handle] RETURNS[recoveryOption:
AE.RecoveryOption] =
TRUSTED BEGIN RETURN[handle.trans.inst.file.GetRecoveryOption[handle.trans.inst.conversation,
handle.openFileID
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]]];
END;

GetReferencePattern: PUBLIC PROCEDURE[handle: AlpF.Handle] RETURNS[referencePattern:
AE.ReferencePattern] =
TRUSTED BEGIN
RETURN[handle.trans.inst.file.GetReferencePattern[handle.trans.inst.conversation,
handle.openFileID
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]]];
END;

SetReferencePattern: PUBLIC PROCEDURE[handle: AlpF.Handle, referencePattern:
AE.ReferencePattern] =
TRUSTED BEGIN handle.trans.inst.file.SetReferencePattern[handle.trans.inst.conversation,
handle.openFileID, referencePattern
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

GetSize: PUBLIC PROCEDURE[handle: AlpF.Handle, lock: AE.LockOption] RETURNS[size:
AE.PageCount] =
TRUSTED BEGIN RETURN[handle.trans.inst.file.GetSize[handle.trans.inst.conversation,
handle.openFileID, lock
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]]];
END;

SetSize: PUBLIC PROCEDURE[handle: AlpF.Handle, size: AE.PageCount, lock: AE.LockOption] =
TRUSTED BEGIN handle.trans.inst.file.SetSize[handle.trans.inst.conversation, handle.openFileID,
size, lock
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

GetUniversalFile: PUBLIC PROCEDURE[handle: AlpF.Handle] RETURNS[universalFile:
AE.UniversalFile] =
TRUSTED BEGIN universalFile ←
handle.trans.inst.file.GetUniversalFile[handle.trans.inst.conversation, handle.openFileID
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

UnlockVersion: PUBLIC PROCEDURE[handle: AlpF.Handle] =
TRUSTED BEGIN handle.trans.inst.file.UnlockVersion[handle.trans.inst.conversation,
handle.openFileID
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

IncrementVersion: PUBLIC PROCEDURE[handle: AlpF.Handle, increment: INT] =
TRUSTED BEGIN handle.trans.inst.file.IncrementVersion[handle.trans.inst.conversation,
handle.openFileID, increment
! RPC.CallFailed => IF why = unbound OR why = timeout THEN
AlpP.NoticeUnboundInstance[handle.trans.inst]];
END;

AccessFailed: PUBLIC ERROR [missingAccess: AE.NeededAccess] ← AF.AccessFailed;
LockFailed: PUBLIC ERROR [why: AE.LockFailure] ← AF.LockFailed;
OperationFailed: PUBLIC ERROR [why: AE.OperationFailure] ← AF.OperationFailed;
StaticallyInvalid: PUBLIC ERROR ← AF.StaticallyInvalid;
Unknown: PUBLIC ERROR [what: AE.UnknownType] ← AF.Unknown;
PossiblyDamaged: PUBLIC SIGNALLOOPHOLE[AF.PossiblyDamaged];



END.
Edit Log

Initial: Kolling: February 14, 1983 5:08 pm: package to aid clients, in conjunction with AlpInstance and AlpTransaction.