FSRemoteFileExtras.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Demers, September 19, 1987 3:12:35 pm PDT
DIRECTORY
BasicTime USING [GMT],
FS USING [FileType, InfoProc, NameProc, tUnspecified],
FSBackdoor USING [Version],
IO USING [STREAM],
Rope USING [ROPE]
;
FSRemoteFileExtras: CEDAR DEFINITIONS
~ {
Copied Types
ROPE: TYPE ~ Rope.ROPE;
GMT: TYPE ~ BasicTime.GMT;
Version: TYPE ~ FSBackdoor.Version;
FileType: TYPE ~ FS.FileType;
Interface to FS
Delete: PROCEDURE [server, file: ROPE, wantedCreatedTime: GMT, proc: ConfirmProc];
Does a delete of the remote file. "proc" is called with the version number of the file to be deleted.
ConfirmProc: TYPE ~ PROC [v: Version] RETURNS [BOOL];
Reports the version number of the file to be acted upon. Returning FALSE stops the action, TRUE allows it to continue.
EnumerateForInfo: PROCEDURE [server, pattern: ROPE, proc: InfoProc];
InfoProc: TYPE ~ FS.InfoProc -- [fullFName, attachedTo: ROPE, created: GMT, bytes: INT, keep: CARDINAL, fileType: FileType] RETURNS [continue: BOOL] -- ;
Reports the info about each file during EnumerateForInfo. Returning FALSE aborts the enumeration. This is a restricted use of FS.InfoProc : attachedTo is always NIL, keep is always 0.
EnumerateForNames: PROCEDURE [server, pattern: ROPE, proc: NameProc];
NameProc: TYPE ~ FS.NameProc -- [fullFName: ROPE] RETURNS [continue: BOOL] -- ;
Reports the info about each file during EnumerateForName. Returning FALSE aborts the enumeration.
Info: PROCEDURE [server, file: ROPE, wantedCreatedTime: GMT]
RETURNS [version: Version, bytes: INT, created: GMT, fileType: FileType];
Rename: PROCEDURE [server, fromFile: ROPE, fromCreated: GMT, toFile: ROPE, proc: ConfirmProc];
Does a rename on a single remote server. "proc" is called with the version number of the "fromFile".
Retrieve: PROCEDURE [server, file: ROPE, wantedCreatedTime: GMT, proc: ConfirmRetrieveProc, checkFileType: BOOLFALSE, fileType: FileType ← FS.tUnspecified];
Tries to find the remote file specified by "server" "file" and "wantedCreatedTime". If the file is located then "proc" is called with the full GName (canonical spelling), bytes and created time. If NIL is returned then Retrieve aborts and returns to its caller. Otherwise, the bytes from the remote file are put into the IO.STREAM; the client must close the IO.STREAM.
ConfirmRetrieveProc: TYPE ~ PROC [fullGName: Rope.ROPE, bytes: INT, created: GMT]
RETURNS [IO.STREAM];
Store: PROCEDURE [server, file: ROPE, str: IO.STREAM, created: GMT, proc: ConfirmProc];
Tries to store the bytes obtained from "str" into the named remote file. Sets the created time of the remote file to "created". "proc" is called with the version number of the file to be created.
Interface to communications layer
Should become FSRemoteFileBackdoor?
Server handles:
ServerHandle: TYPE ~ REF ServerObject;
ServerObject: TYPE ~ RECORD [
flavor: ATOM,
name: ROPE,
procs: ServerProcs,
data: REF
];
ServerProcs: TYPE ~ REF ServerProcsObject;
ServerProcsObject: TYPE ~ RECORD [
sweep: SweepProc ← NIL,
validate: ValidateProc,
delete: DeleteProc,
enumerateForInfo: EnumerateForInfoProc,
enumerateForNames: EnumerateForNamesProc,
getInfo: GetInfoProc,
rename: RenameProc,
retrieve: RetrieveProc,
store: StoreProc
];
SweepProc: TYPE ~ PROC [h: ServerHandle, seconds: INT];
Called a few times a minute by this package for miscellaneous housekeeping:
ValidateProc: TYPE ~ PROC [h: ServerHandle] RETURNS [ok: BOOL];
Called to validate a handle that might be stale:
The following are called to perform file operations. They should raise appropriate FS.Error's to indicate failure:
DeleteProc: TYPE ~ PROC [h: ServerHandle, file: ROPE, wantedCreatedTime: GMT, proc: ConfirmProc];
EnumerateForInfoProc: TYPE ~ PROC [h: ServerHandle, pattern: ROPE, proc: InfoProc];
EnumerateForNamesProc: TYPE ~ PROC [h: ServerHandle, pattern: ROPE, proc: NameProc];
GetInfoProc: TYPE ~ PROC [h: ServerHandle, file: ROPE, wantedCreatedTime: GMT]
RETURNS [version: Version, bytes: INT, created: GMT, fileType: FileType];
RenameProc: TYPE ~ PROC [h: ServerHandle, fromFile: ROPE, fromCreated: GMT, toFile: ROPE, proc: ConfirmProc];
RetrieveProc: TYPE ~ PROC [h: ServerHandle, file: ROPE, wantedCreatedTime: GMT, proc: ConfirmRetrieveProc, checkFileType: BOOL, fileType: FileType];
StoreProc: TYPE ~ PROC [h: ServerHandle, file: ROPE, str: IO.STREAM, created: GMT, proc: ConfirmProc];
Registration
Register: PROC [flavor: ATOM, getServer: GetServerProc];
Register an(other) remote file ops implementation. Any existing registration for "flavor" disappears. "getServer" may be NIL, to clear a registration.
GetServerProc: TYPE ~ PROC [server: ROPE] RETURNS [h: ServerHandle];
Try to find a server of the given name.
Should return NIL if no server responds and no server is known to exist.
Should return an unusable handle (i.e. a handle such that every operation will raise FS.Error) if server is known to exist but is not responding.
Should not raise FS.Error itself!
The caller may Process.Abort this proc.
Controlling the flavor of a cached server.
If this is necessary the network environment is probably screwed up.
SetCachedServer: PROC [server: ROPE, flavor: ATOM];
Force server of given name to be of given flavor.
ClearCachedServer: PROC [server: ROPE];
}...