-- File DBFileImpl.Mesa
-- Last edited by:
-- MBrown on February 22, 1983 11:59 am
-- Willie-sue, February 3, 1983 10:46 am
-- Cattell, September 14, 1983 12:17 pm
DIRECTORY
DBCommon,
DBEnvironment,
DBFile,
DBFileAlpine,
Rope;
DBFileImpl: PROGRAM
IMPORTS
DBEnvironment,
DBFileAlpine,
Rope
EXPORTS
DBFile
= BEGIN
ROPE: TYPE = Rope.ROPE;
OpenFileHandle: TYPE = DBCommon.OpenFileHandle;
Trans: TYPE = DBCommon.Trans;
FileSystem: TYPE = DBCommon.FileSystem;
SegmentIndex: TYPE = DBCommon.SegmentIndex;
VersionOptions: TYPE = DBCommon.VersionOptions;
DBPage: TYPE = DBCommon.DBPage;
NullDBPage: DBPage = DBCommon.NullDBPage;
FileServerFromFileName: PUBLIC PROC [file: ROPE]
RETURNS [server: ROPE] = {
rightSquareBracket: INT;
IF file.Fetch[0] # '[ THEN ERROR;
rightSquareBracket ← file.SkipTo[1, "]"];
IF rightSquareBracket = file.Length[] THEN ERROR;
RETURN [file.Substr[start: 1, len: rightSquareBracket-1]];
};
PagesFromBytes: PUBLIC PROC [bytes: INT]
RETURNS [pages: CARDINAL] = {
IF bytes < 0 OR bytes > LONG[CARDINAL.LAST - 1]*DBCommon.BytesPerPage THEN
ERROR;
RETURN [(bytes+DBCommon.BytesPerPage-1)/DBCommon.BytesPerPage];
};
BytesFromPages: PUBLIC PROC [pages: CARDINAL]
RETURNS [bytes: INT] = {
RETURN [pages*DBCommon.BytesPerPage];
};
CreateTransaction: PUBLIC PROC [server: ROPE] RETURNS [t: Trans] = {
IF FileSystemFromServerName[server] = alpine THEN
RETURN [DBFileAlpine.CreateTransaction[server]]
ELSE
ERROR DBEnvironment.InternalError;
};
FileSystemFromServerName: PROC [server: ROPE]
RETURNS [fileSystem: FileSystem] = {
IF Rope.Equal[s1: server, s2: "Local", case: FALSE] THEN RETURN[pilot]
ELSE RETURN [alpine];
};
FinishTransaction: PUBLIC PROC [t: Trans, abort: BOOL, continue: BOOL] = {
DBFileAlpine.FinishTransaction[t, abort, continue];
};
OpenFile: PUBLIC PROC [t: Trans, file: ROPE, version: VersionOptions,
discardFileContents: BOOL, nPagesInitial: INT, readOnly: BOOL, noLog: BOOL]
RETURNS [f: OpenFileHandle, createdFile: BOOL] = {
flatFile: Rope.Text = Rope.Flatten[file];
[f, createdFile] ← DBFileAlpine.OpenFile[
NARROW[t], flatFile, version, discardFileContents, nPagesInitial, readOnly, noLog];
};
ReadFilePage: PUBLIC PROC [
f: OpenFileHandle, p: CARDINAL, corePage: LONG POINTER] = {
DBFileAlpine.ReadFilePage[NARROW[f], p, corePage];
};
WriteFilePage: PUBLIC PROC [
f: OpenFileHandle, p: CARDINAL, corePage: LONG POINTER] = {
DBFileAlpine.WriteFilePage[NARROW[f], p, corePage];
};
GetSize: PUBLIC PROC [f: OpenFileHandle] RETURNS [nPages: CARDINAL] = {
RETURN[DBFileAlpine.GetSize[NARROW[f]]];
};
SetSize: PUBLIC PROC [f: OpenFileHandle, nPages: CARDINAL] = {
DBFileAlpine.SetSize[NARROW[f], nPages];
};
END.
CHANGE LOG
Created by MBrown on February 26, 1981 10:17 PM
Changed by MBrown on February 28, 1981 5:15 PM
-- Created Pilot version: Pilot file system is server named "Local".
Changed by MBrown on 19-Jun-81 16:22:29
-- Conversion to Cedar (use Rope.Match, make fileProcs a REF.)
Changed by Willie-Sue on June 24, 1982 12:11 pm
-- Rope.Ref => Rope.ROPE
Changed by MBrown on November 29, 1982 11:18 am
-- Allow multiple file systems active at once.
Changed by MBrown on January 15, 1983 8:10 pm
-- Enable Alpine files (used to ERROR).
Changed by Willie-Sue on February 3, 1983
-- added noLog arg to OpenFile
Changed by MBrown on February 7, 1983 12:19 pm
-- Add discardFileContents parm to OpenFile, flush Juniper support, flush initialized
--array (was used to init Pine).
Changed by MBrown on February 22, 1983 11:58 am
-- Eliminate compilation dependency on AlpineEnvironment.
Changed by Cattell on July 11, 1983 10:51 am
-- Pass read-only bit through to DBFileAlpine.OpenFile, so no write locks on Alpine files.