Text preview for : Files.mesa_Oct77.pdf part of xerox Files.mesa Oct77 xerox mesa 3.0_1977 listing Files.mesa_Oct77.pdf



Back to : Files.mesa_Oct77.pdf | Home

files.mESA 24-0CT-77 13:23:01 Page 1


-- Files.Mesa Edited by Sandman on August 29, 1977 8:44 AM
DIRECTORY
AltoDefs: FROM "altodefs",
AltoFileDefs: FROM "altofiledefs",
BFSDefs: FROM "bfsdefs",
BootDefs: FROM "bootdefs",
DirectoryDefs: FROM "directorydefs",
DiskKDDefs: FROM "diskkddefs",
InlineDefs: FROM "inlinedefs",
MiscDefs: FROM "miscdefs",
SegmentDefs: FROM "segmentdefs";
DEFINITIONS FROM AltoFileDefs, SegmentDefs:
Files: PROGRAM
IMPORTS BFSDefs, BootDefs, DirectoryDefs, DiskKDDefs. SegmpntDefs
EXPORTS BootDefs, MiscDefs. SegmentDefs SHARES SegmentOefs ~ BEGIN
FileError: PUBLIC SIGNAL [file:FileHandle] ~ CODE;
FileNameError: PUBLIC SIGNAL [name:STRING] ~ CODE;
FileAccessError: PUBLIC SIGNAL [file:FileHandle] = CODE;
NullFileObject: FileObject ~ Object [ TRUE,FALSE,
File [ FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,O,O,O,
FP[SN[l,O,l,17777B,177777B],eofOA],FA(eofDA.O,O]]];
NewFile: PUBLIC PROCEDURE [
name:STRING, access:AccessOptions, version:VersionOptions]
RETURNS [file:FileHandle] =
BEGIN OPEN InlineOefs;
fp: FP; old, create: BOOLEAN;
[access,version] ~ ValidateOptions[access,version];
create ~ BITAND[version.OldFileOnly]=O;
old ~ OirectoryDefs.DirectoryLookup[@fp.name,create];
IF (old AND BITAND(version.NewFileOn1y]#O)
OR (-old AND -create) THEN ERROR Fi1eNameError[name];
IF (file ~ FindFi1e[@fp]) ~ NIL THEN
BEGIN
file ~ A110cateFi1e[Fi1eTab1e];
fi1e~ ~ Nu11Fi1eObject;
file. fp ~ fp;
END;
SetFileAccess[fi1e,access];
RETURN
END;
InsertFi1e: PUBLIC PROCEDURE [
fp:POINTER TO FP, access:AccessOptions]
RETURNS [fi1e:Fi1eHand1e] = BEGIN
[access,] .. Val idateOptions[access.O];
IF (file ~ Findfi1e[fp]) = NIL THEN
BEGIN
file ~ A110cateFile[Fi1eTab1e];
fi1e~ ~ Nu11Fi1eObject;
file, fp ~ fp~;
END;
SetFi1eAccess[fi1e,access);
RFTURN
END;
BootFi1e: PUBL IC PROCrDURE [access:AccessOptions]
RrTURNS [fi1e:rilellandle] = BfGIN
[access.] .. Val idateOptions[access,O];
file" Al10caterile[Fi1eTab1e]:
filet .. Nul1fi1eObject:
SelrileAccess[file,access]:
RrTURN
[NO:
Val idaleOplions: PROCroURf [
access:AccessOpLions, version:VersionOplions]
RrTURNS [AccessOplions, VersionOptions] =
BfGIN OprN InlineOefs:
If access = rlefaul tAccess TllrN access" Read:
-- If vers ion = DefaullVe,'s ion TllfN vers ion" 0:
files.mESA 24-0CT-77 18:23:01 Page 2


IF BITAND(version,NewFileOnly+OldFileOnly] = NewFileOnly+OldFileOnly
OR (BITAND[version,NewFileOnly)#O AND BITAND[access,Append]=O)
THEN ERROR FileAccessError[NIL]:
IF BITAND[access,Append]=O THEN
version ~ BITOR[version,OldFileOnly]:
RETURN[access,version]
END:
GetFileAccess: PUBLIC PROCEDURE [file:FileHandle]
RETURNS [AccessOptions] = BEGIN
access: AccessOptions ~ 0:
ValidateFile[FileTable,file):
IF file.read THEN access ~ access+Read:
IF file.write THEN access ~ access+Write;
IF file.append THEN access ~ access+Append:
RETURN[access]
END;
SetFileAccess: PUBLIC PROCEDURE [file:FileHandle, access:AccessOptions]
BEGIN OPEN InlineDefs;
ValidateFile[FileTable,file]:
IF access = DefaultAccess THEN access ~ Read;
file.read ~ file.read OR BITANO[access,Read)HO;
file.write ~ file.write OR BITAND[access,Write)#O;
file.append ~ file.append OR BITAND[access,Append)#O;
RETURN
END;
LockFile: PUBLIC PROCEDURE [file:FileHandle]