DFInternal.mesa
last edited by Levin on November 23, 1983 12:48 am
DIRECTORY
DFOperations USING [InfoClass, InteractionProc],
DFUtilities USING [Date],
FS USING [ErrorDesc],
IO USING [STREAM],
Rope USING [ROPE];
DFInternal: CEDAR DEFINITIONS =
BEGIN
OPEN Ops: DFOperations, Utils: DFUtilities;
ROPE: TYPE = Rope.ROPE;
Interaction Stuff
Client: TYPE = REF ClientDescriptor;
ClientDescriptor: TYPE = RECORD [
proc: Ops.InteractionProc,
data: REF ANY, -- to be passed as 'clientData' parameter of 'proc'
log: IO.STREAM
];
SimpleInteraction: PROC [client: Client, interaction: REF ANY];
Used for any `interaction' that doesn't expect a response. Abort processing is handled internally, with 'DoAbort' being invoked.
YesOrNo: PROC [client: Client, message: ROPE, default: BOOL] RETURNS [BOOL];
Used for Ops.YesNoInteraction. Abort processing is handled internally, with 'DoAbort' being invoked.
DoInteraction: PROC [client: Client, interaction: REF ANY] RETURNS [response: REF ANY];
Used for the general case, including (for now) Ops.ChoiceInteraction. Abort processing is handled internally, with 'DoAbort' being invoked.
CheckAbort: PROC [client: Client];
interacts with the client and, if an abort is requested, triggers 'DoAbort'.
DoAbort: PROC [
log: IO.STREAM,
message: ROPENIL, proc: Ops.InteractionProc ← NIL, clientData: REF ANYNIL];
If 'proc' and 'message' are non-NIL, an InfoInteraction occurs. The message is then logged on 'log'. Finally, AbortDF is raised.
AbortDF: ERROR;
raised only by DoAbort.
DefaultInteractionProc: Ops.InteractionProc;
to be used when callers of DFOperations procedures have 'interact' = NIL.
File Info Stuff
LocalFileInfo: TYPE = RECORD [
name: ROPE,
attachedTo: ROPE,
date: Utils.Date ← [],
keep: INT ← -1
];
RemoteFileInfo: TYPE = RECORD [
name: ROPE,
date: Utils.Date ← []
];
GetFileInfo: PROC [
info: REF ANY, notFoundOK: BOOLFALSE,
client: Client ← NIL, errorLevel: Ops.InfoClass ← $error];
'info' must be either REF LocalFileInfo or REF RemoteFileInfo.
Behavior for ISTYPE[info, REF LocalFileInfo] = TRUE: info.name is assumed to describe a local file. The file is looked up and, if found, info.date.format is set to $explicit and info.date.gmt is set to the file's create date. If the file doesn't exist and notFoundOK is TRUE, info.date is set to [$omitted, BasicTime.nullGMT]. All other cases trigger error handling, discussed below.
Behavior for ISTYPE[info, REF RemoteFileInfo] = TRUE: The remote file specified by info.name and info.date is looked up, using a create time search on info.date.gmt if info.date.format = $explicit. If the file exists, info.date.format is set to $explicit and info.date.gmt is set to the file's create date. If the file doesn't exist and notFoundOK is TRUE, info.date is set to [$omitted, BasicTime.nullGMT]. All other cases trigger error handling, discussed below.
Error handling: Except as described above, all occurrences of FS.Error propagate to the client. However, if the caller supplies a non-NIL value for 'client', substantial error handling will first occur internally. In this case (client ~= NIL), RetryFSOperation will be called. If it returns TRUE, GetFileInfo will be (re)executed in its entirety. If RetryFSOperation returns FALSE, ReportFSError will be called with the obvious parameters.
LocalFile: PROC [file: ROPE] RETURNS [BOOL];
ShortName: PROC [file: ROPE, keepVersion: BOOLFALSE] RETURNS [ROPE];
Error Handling
RetryFSOperation: PROC [error: FS.ErrorDesc, client: Client] RETURNS [retry: BOOL];
determines whether a retry of an FS operation is appropriate. Any necessary waiting has been done inside this procedure (client can simply say RETRY in catch phrase).
ReportFSError: PROC [
error: FS.ErrorDesc, info: REF ANY, client: Client, errorLevel: Ops.InfoClass ← $error];
'info' is either REF LocalInfo or REF RemoteInfo
END.