File DBFile.mesa
Copyright c 1985 by Xerox Corporation. All rights reserved.
Last edited by:
MBrown on February 7, 1983 12:10 pm
Cattell on May 10, 1984 6:24:44 pm PDT
Willie-Sue on April 25, 1985 12:34:09 pm PST
Last Edited by: Wert, July 26, 1984 4:33:53 pm PDT
Donahue, November 13, 1985 11:20:46 am PST
Widom, August 15, 1985 10:37:19 am PDT
DIRECTORY
AlpineEnvironment USING [LockOption],
AlpTransaction USING [Handle],
DBCommon,
Rope USING [ROPE];
DBFile: CEDAR DEFINITIONS = BEGIN
ROPE: TYPE = Rope.ROPE;
AlpTrans: TYPE = AlpTransaction.Handle;
VersionOptions: TYPE = DBCommon.VersionOptions;
OpenFileHandle: TYPE = DBCommon.OpenFileHandle;
Transactions
CreateTransaction: PROC [server: ROPE] RETURNS [t: AlpTrans];
Creates a new transaction on the given server, and returns it.
FinishTransaction: PROC [t: AlpTrans, abort: BOOL, continue: BOOL];
If NOT abort AND continue, then t continues as a valid transaction, all open files remain open, etc, but all updates are committed.
Files
PagesFromBytes: PROC [bytes: INT] RETURNS [pages: CARDINAL];
BytesFromPages: PUBLIC PROC [pages: CARDINAL] RETURNS [bytes: INT];
OpenFile: PROC [t: AlpTrans, file: ROPE, version: VersionOptions,
discardFileContents: BOOL, nPagesInitial: INT, lock: AlpineEnvironment.LockOption, readOnly: BOOL] RETURNS [f: OpenFileHandle, createdFile: BOOL];
Creates an "open file" f, that is used to access file "file" under transaction "t". If version = NewFileOnly or None, will create file of nPagesInitial pages if necessary. (The full path name must contain enough information, and must be consistent with transaction t). If discardFileContents, then the contents of the open file are undefined (and performance may be considerably better).
Close: PROC [f: OpenFileHandle];
ReadFilePage: PROC [f: OpenFileHandle, p: CARDINAL, corePage: LONG POINTER];
Reads page p of file f into corePage. The page size is given by
DBCommon.WordsPerPage.
WriteFilePage: PROC [f: OpenFileHandle, p: CARDINAL, corePage: LONG POINTER];
Writes corePage onto page p of file f. Raises ERROR if the user who opened f does not have write access to f. The page size is given by DBCommon.WordsPerPage.
GetSize: PROC [f: OpenFileHandle] RETURNS [nPages: CARDINAL];
Returns the size of the file (in pages). If the length of the file is not multiple of 512 bytes, ERROR Fatal[IllegalFileLength] is raised.
SetSize: PROC [f: OpenFileHandle, nPages: CARDINAL];
Sets the size (number of pages) of the file.
END.