DIRECTORY CrRPC USING [Handle], IO USING [STREAM], PFS USING [RopeFromPath, FileType, InfoProc, Mutability, nullUniqueID, tUnspecified, UniqueID], PFSBackdoor USING [ProduceError], PFSClass USING [AttachProc, CloseProc, CopyProc, DeleteProc, EnumerateClientPropertiesProc, EnumerateForInfoProc, EnumerateForNamesProc, FileInfoProc, FileManipulationProcs, FileManipulationProcsObject, FSHandle, FSObject, GetClientPropertyProc, GetHandleProc, GetInfoProc, LookupNameProc, MaintenanceProcs, MaintenanceProcsObject, OpenFile, OpenFileObject, OpenProc, ReadProc, Register, RenameProc, RetrieveProc, SetAttributesProc, SetByteCountAndUniqueIDProc, SetClientPropertyProc, StoreProc, SweepProc, ValidateProc, WriteProc], PFSNames USING [Component, PATH, ShortName, Version], Rope USING [ROPE], XNSFilingFileMgr USING [CloseFileOp, OpenFile, OpenFileOp, ReadFileOp, WriteFileOp], XNSFilingOps USING [CallProtected, EnumProc, EnumerateOp], XNSFilingPrivate USING [DebugOut], XNSFilingSession USING [ServerHandle, XNSGetServer, XNSSweep, XNSValidate]; XNSFilingViewImpl: CEDAR MONITOR LOCKS tr USING tr: Transport IMPORTS PFS, PFSBackdoor, PFSClass, PFSNames, XNSFilingFileMgr, XNSFilingOps, XNSFilingPrivate, XNSFilingSession ~ { OPEN XNSFilingFileMgr, XNSFilingOps, XNSFilingSession; ROPE: TYPE ~ Rope.ROPE; xnsFlavor: ATOM ~ $XNS; mo: PFSClass.MaintenanceProcs ~ NEW [PFSClass.MaintenanceProcsObject _ [ sweep: Sweep, validate: Validate ]]; fmo: PFSClass.FileManipulationProcs ~ NEW[PFSClass.FileManipulationProcsObject _ [ delete: Delete, enumerateForInfo: EnumerateForInfo, enumerateForNames: EnumerateForNames, fileInfo: FileInfo, lookupName: Lookup, rename: Rename, copy: Copy, setAttributes: SetAttributes, setByteCountAndUniqueID: SetByteCountAndUniqueID, setClientProperty: SetClientProperty, getClientProperty: GetClientProperty, enumerateClientProperties: EnumerateClientProperties, read: Read, write: Write, open: Open, close: Close, store: Store, retrieve: Retrieve, attach: Attach, getInfo: GetInfo ]]; vfsClass: PFSClass.FSHandle ~ NEW [PFSClass.FSObject _ [ flavor: xnsFlavor, name: NIL, -- filled in upon instantiation maintenanceProcs: mo, procs: fmo, data: NIL -- filled in upon instantiation ]]; TransportProc: TYPE ~ PROC; -- [tr: Transport]; Transport: TYPE ~ REF TransportBody; TransportBody: TYPE ~ MONITORED RECORD [ crH: CrRPC.Handle, vfs: VFS ]; CallMonitored: PROC [vfs: VFS, inner: TransportProc] ~ { CallProtected[vfs.sH.mnt, inner]; }; VFS: TYPE ~ REF VFSInstance; VFSInstance: TYPE ~ RECORD [ fs: ROPE, flavorSpecified: BOOL, sH: ServerHandle ]; GetHandle: PFSClass.GetHandleProc ~ { vfs: VFS ~ NEW[VFSInstance _ [fs: fs, flavorSpecified: flavorSpecified, sH: NIL] ]; { sH: ServerHandle; downMsg _ NIL; [sH, downMsg] _ XNSGetServer[fs]; vfs.sH _ sH; }; h _ NEW[PFSClass.FSObject _ vfsClass^]; h.name _ fs; h.data _ vfs; }; Sweep: PFSClass.SweepProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; sH: ServerHandle ~ vfs.sH; XNSSweep[sH, seconds]; NULL; }; Validate: PFSClass.ValidateProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; sH: ServerHandle ~ vfs.sH; obsolete _ FALSE; downMsg _ NIL; [obsolete, downMsg] _ XNSValidate[sH]; IF ( FALSE ) THEN { obsolete _ TRUE; downMsg _ NIL }; IF ( FALSE ) THEN { obsolete _ FALSE; downMsg _ "downMsg" }; }; EnumerateForInfo: PFSClass.EnumerateForInfoProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; pat: ROPE ~ PFS.RopeFromPath[pattern]; EnumerateForInfoInner: TransportProc ~ { ENABLE UNWIND => { NULL }; Lister: EnumProc ~ { fullFName: PFSNames.PATH _ pathy; attachedTo: PFSNames.PATH _ NIL; uniqueID: PFS.UniqueID _ [[time: eInfo.created]]; bytes: INT _ eInfo.bytes; mutability: PFS.Mutability _ $immutable; -- policy decision! fileType: PFS.FileType _ [eInfo.fileType]; -- identical type defs? continue _ IF ( proc = NIL ) THEN TRUE ELSE proc[fullFName, attachedTo, uniqueID, bytes, mutability, fileType]; }; EnumerateOp[vfs.sH.mnt, pattern, Lister, $enumerate]; }; XNSFilingPrivate.DebugOut["XNSFilingViewImpl.EnumerateForInfo"]; XNSFilingPrivate.DebugOut[PFS.RopeFromPath[pattern]]; CallMonitored[vfs, EnumerateForInfoInner]; }; EnumerateForNames: PFSClass.EnumerateForNamesProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; Info: PFS.InfoProc ~ { name: PFSNames.PATH ~ fullFName; continue _ IF ( proc = NIL ) THEN TRUE ELSE proc[name]; }; XNSFilingPrivate.DebugOut["XNSFilingViewImpl.EnumerateForNames"]; XNSFilingPrivate.DebugOut[PFS.RopeFromPath[pattern]]; EnumerateForInfo[h, pattern, Info, lbound, hbound]; }; FileInfo: PFSClass.FileInfoProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; pattern: PFSNames.PATH ~ file; zversion: PFSNames.Version _ [none]; zattachedTo: PFSNames.PATH _ NIL; zuniqueID: PFS.UniqueID _ PFS.nullUniqueID; zbytes: INT _ 0; zmutability: PFS.Mutability _ $immutable; zfileType: PFS.FileType _ PFS.tUnspecified; Info: PFS.InfoProc ~ { shortName: PFSNames.Component ~ PFSNames.ShortName[fullFName]; SELECT TRUE FROM ( wantedUniqueID = PFS.nullUniqueID ) => { continue _ TRUE; }; ( uniqueID = wantedUniqueID ) => { continue _ FALSE }; ENDCASE => { RETURN }; zversion _ shortName.version; zattachedTo _ attachedTo; zbytes _ bytes; zuniqueID _ uniqueID; zmutability _ mutability; zfileType _ fileType; }; XNSFilingPrivate.DebugOut["XNSFilingViewImpl.FileInfo"]; XNSFilingPrivate.DebugOut[PFS.RopeFromPath[pattern]]; EnumerateForInfo[h, pattern, Info, NIL, NIL]; RETURN[zversion, zattachedTo, zbytes, zuniqueID, zmutability, zfileType]; }; GetInfo: PFSClass.GetInfoProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; XNSFilingPrivate.DebugOut["XNSFilingViewImpl.GetInfo"]; fullFName _ file.fullFName; attachedTo _ file.attachedTo; uniqueID _ file.uniqueID; bytes _ file.bytes; mutability _ file.mutability; fileType _ file.fileType; }; Read: PFSClass.ReadProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; ReadInner: TransportProc ~ { ENABLE UNWIND => { NULL }; xnsFile: XNSFilingFileMgr.OpenFile ~ NARROW[file.data]; bytesRead _ ReadFileOp[vfs.sH.mnt, xnsFile, filePosition, nBytes, to]; }; bytesRead _ 0; CallMonitored[vfs, ReadInner]; }; Write: PFSClass.WriteProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; WriteInner: TransportProc ~ { ENABLE UNWIND => { NULL }; xnsFile: XNSFilingFileMgr.OpenFile ~ NARROW[file.data]; XNSFilingPrivate.DebugOut["XNSFilingViewImpl.WriteInner"]; XNSFilingPrivate.DebugOut[PFS.RopeFromPath[file.fullFName]]; bytesWritten _ WriteFileOp[vfs.sH.mnt, xnsFile, filePosition, nBytes, from]; }; bytesWritten _ 0; CallMonitored[vfs, WriteInner]; }; Close: PFSClass.CloseProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; CloseInner: TransportProc ~ { ENABLE UNWIND => { NULL }; xnsFile: XNSFilingFileMgr.OpenFile ~ NARROW[file.data]; XNSFilingPrivate.DebugOut["XNSFilingViewImpl.CloseInner"]; XNSFilingPrivate.DebugOut[PFS.RopeFromPath[file.fullFName]]; CloseFileOp[vfs.sH.mnt, xnsFile]; }; CallMonitored[vfs, CloseInner]; }; Open: PFSClass.OpenProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; LegitimateMatch: PROC RETURNS [match: BOOL] ~ { match _ TRUE; }; version: PFSNames.Version; attachedTo: PFSNames.PATH; bytes: INT; uniqueID: PFS.UniqueID; mutability: PFS.Mutability; zfileType: PFS.FileType; of: PFSClass.OpenFile _ NIL; OpenInner: TransportProc ~ { ENABLE UNWIND => { NULL }; fullFName: PFSNames.PATH ~ file; fs: PFSClass.FSHandle ~ h; xnsFile: XNSFilingFileMgr.OpenFile ~ OpenFileOp[vfs.sH.mnt, fullFName]; data: REF ~ xnsFile; new: PFSClass.OpenFile ~ NEW[PFSClass.OpenFileObject _ [fs, fullFName, attachedTo, uniqueID, bytes, mutability, zfileType, $open, data]]; XNSFilingPrivate.DebugOut["XNSFilingViewImpl.OpenInner"]; XNSFilingPrivate.DebugOut[PFS.RopeFromPath[fullFName]]; of _ new; }; [version, attachedTo, bytes, uniqueID, mutability, zfileType] _ FileInfo[h, file, wantedUniqueID]; IF ( NOT LegitimateMatch[] ) THEN { PFSBackdoor.ProduceError[unknownFile, "XNSFilingViewImpl.OpenInner"]; RETURN[NIL]; -- not reached! }; XNSFilingPrivate.DebugOut["XNSFilingViewImpl.Open"]; XNSFilingPrivate.DebugOut[PFS.RopeFromPath[file]]; CallMonitored[vfs, OpenInner]; RETURN[of]; }; UnImplemented: PROC [msg: ROPE] ~ { XNSFilingPrivate.DebugOut[msg]; PFSBackdoor.ProduceError[notImplemented, msg]; }; Delete: PFSClass.DeleteProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; DeleteInner: TransportProc ~ { ENABLE UNWIND => { NULL }; fullName: PFSNames.PATH _ NIL; uniqueID: PFS.UniqueID _ PFS.nullUniqueID; UnImplemented["XNSFilingViewImpl.DeleteInner"]; }; CallMonitored[vfs, DeleteInner]; }; Lookup: PFSClass.LookupNameProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; path: PFSNames.PATH; LookupInner: TransportProc ~ { ENABLE UNWIND => { NULL }; path _ NIL; UnImplemented["XNSFilingViewImpl.LookupInner"]; }; CallMonitored[vfs, LookupInner]; RETURN[path]; }; Rename: PFSClass.RenameProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; RenameInner: TransportProc ~ { ENABLE UNWIND => { NULL }; done _ TRUE; UnImplemented["XNSFilingViewImpl.RenameInner"]; }; CallMonitored[vfs, RenameInner]; }; Copy: PFSClass.CopyProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; CopyInner: TransportProc ~ { ENABLE UNWIND => { NULL }; done _ TRUE; UnImplemented["XNSFilingViewImpl.CopyInner"]; }; CallMonitored[vfs, CopyInner]; }; SetAttributes: PFSClass.SetAttributesProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; SetAttributesInner: TransportProc ~ { ENABLE UNWIND => { NULL }; NULL; UnImplemented["XNSFilingViewImpl.SetAttributesInner"]; }; CallMonitored[vfs, SetAttributesInner]; }; SetByteCountAndUniqueID: PFSClass.SetByteCountAndUniqueIDProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; SetByteCountAndUniqueIDInner: TransportProc ~ { ENABLE UNWIND => { NULL }; NULL; UnImplemented["XNSFilingViewImpl.SetByteCountAndUniqueIDInner"]; }; CallMonitored[vfs, SetByteCountAndUniqueIDInner]; }; SetClientProperty: PFSClass.SetClientPropertyProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; SetClientPropertyInner: TransportProc ~ { ENABLE UNWIND => { NULL }; NULL; UnImplemented["XNSFilingViewImpl.SetClientPropertyInner"]; }; CallMonitored[vfs, SetClientPropertyInner]; }; GetClientProperty: PFSClass.GetClientPropertyProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; GetClientPropertyInner: TransportProc ~ { ENABLE UNWIND => { NULL }; propertyValue _ NIL; UnImplemented["XNSFilingViewImpl.GetClientPropertyInner"]; }; CallMonitored[vfs, GetClientPropertyInner]; }; EnumerateClientProperties: PFSClass.EnumerateClientPropertiesProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; EnumerateClientPropertiesInner: TransportProc ~ { ENABLE UNWIND => { NULL }; propertyName: ROPE; propertyValue: ROPE; UnImplemented["XNSFilingViewImpl.EnumerateClientPropertiesInner"]; }; CallMonitored[vfs, EnumerateClientPropertiesInner]; }; Store: PFSClass.StoreProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; StoreInner: TransportProc ~ { ENABLE UNWIND => { NULL }; fullName: PFSNames.PATH _ NIL; UnImplemented["XNSFilingViewImpl.StoreInner"]; }; CallMonitored[vfs, StoreInner]; }; Retrieve: PFSClass.RetrieveProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; RetrieveInner: TransportProc ~ { ENABLE UNWIND => { NULL }; fullFName: PFSNames.PATH _ NIL; bytes: INT _ 0; uniqueID: PFS.UniqueID _ PFS.nullUniqueID; UnImplemented["XNSFilingViewImpl.RetrieveInner"]; }; CallMonitored[vfs, RetrieveInner]; }; Attach: PFSClass.AttachProc ~ { class: PFSClass.FSHandle ~ h; vfs: VFS ~ NARROW[class.data]; AttachInner: TransportProc ~ { ENABLE UNWIND => { NULL }; toFName _ NIL; UnImplemented["XNSFilingViewImpl.AttachInner"]; }; CallMonitored[vfs, AttachInner]; }; Init: PROC ~ { PFSClass.Register[xnsFlavor, GetHandle]; }; Init[]; }. V XNSFilingViewImpl.mesa Copyright Σ 1990 by Xerox Corporation. All rights reserved. Bill Jackson (bj), May 30, 1990 2:02 pm PDT PFS Class name Maintenance Object File Manipulation Object Initialized Data - order is important! Transport Management crH: CrRPC.Handle ~ NIL; link: Transport ~ NEW[TransportBody _ [crH, vfs]]; UnderLock: --ENTRY-- TransportProc ~ { ENABLE UNWIND => { NULL }; inner[]; }; UnderLock[link]; XNS Virtual File System(s) Attempt to Attach new vfs[h] Maintenance Operations File Manipulation Procs eFile: PFSNames.PATH, eInfo: Info, pathy: PFSNames.PATH createdOn: CARD32 ~ BasicTime.ToNSTime[wantedUniqueID.egmt.time]; EnumerateForNamesInner: TransportProc ~ { ENABLE UNWIND => { NULL }; UnImplemented["XNSFilingViewImpl.EnumerateForNamesInner"]; }; CallMonitored[vfs, EnumerateForNamesInner]; perhaps we should be checking for the *best* match? FileInfoInner: TransportProc ~ { ENABLE UNWIND => { NULL }; UnImplemented["XNSFilingViewImpl.FileInfoInner"]; }; CallMonitored[vfs, FileInfoInner]; Generic Implementation GetInfoInner: TransportProc ~ { ENABLE UNWIND => { NULL }; UnImplemented["XNSFilingViewImpl.GetInfoInner"]; }; CallMonitored[vfs, GetInfoInner]; File Operations XNSFilingPrivate.DebugOut["XNSFilingViewImpl.ReadInner"]; XNSFilingPrivate.DebugOut[PFS.RopeFromPath[file.fullFName]]; file: PATH, wantedUniqueID: UniqueID, access: PFS.AccessOptions, checkFileType: BOOL, fileType: PFS.FileType, createOptions: PFS.CreateOptions Utilities UnImplemented so far... continue: BOOL _ IF ( proc = NIL ) THEN TRUE ELSE proc[fullName, uniqueID]; continue: BOOL _ IF ( proc = NIL ) THEN TRUE ELSE proc[propertyName, propertyValue]; continue: BOOL _ IF ( proc = NIL ) THEN TRUE ELSE proc[fullName]; s: IO.STREAM _ IF ( proc = NIL ) THEN NIL ELSE proc[fullFName, bytes, uniqueID]; IF ( s = NIL ) THEN ERROR; PFSClass.ClearCachedServer["*-XNS"]; ΚΔ•NewlineDelimiter ™codešœ™K™˜TKšœ œ(˜:Kšœœ ˜"Kšœœ5˜KK˜—š Οnœœœœœ˜=Kšœœi˜tKšœ2˜6Kšœœœ˜headšΟz™KšΟb œœ˜—šŸ™š œœ%˜HKšœ ˜ Kšœ˜Kšœ˜——šŸ™š œ#œ)˜RK˜Kšœ#˜#Kšœ%˜%Kšœ˜Kšœ˜Kšœ˜Kšœ ˜ Kšœ˜Kšœ1˜1Kšœ%˜%Kšœ%˜%Kšœ5˜5Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ ˜ Kšœ˜Kšœ˜K˜Kšœ˜——šŸ&™&š œœ˜8Kšœ  œ˜KšœœΟc˜*Kšœ œ˜Kšœ œ˜ Kšœœ‘˜)Kšœ˜——šŸ™Kšœœœ‘˜0Kšœ œœ˜$šœœ œœ˜(Kšœ˜Kšœ˜Kšœ˜K˜—šž œœœ˜8Kšœœ™Kšœœ™2šž œ‘ œ™&Kšœœœ™Kšœ™Kšœ™—Kšœ™Kšœ!˜!Kšœ˜——šŸ™Kšœœœ ˜šœ œœ˜Kšœœ˜ Kšœœ˜Kšœ˜Kšœ˜K˜—šž œ˜%Kšœœœ>œ˜S˜K™Kšœœ˜ Kšœ!˜!Kšœ ˜ Kšœ˜—Kšœœ œ˜'Kšœ ˜ Kšœ ˜ Kšœ˜——šŸ™šžœ˜Kšœ˜Kšœœœ ˜Kšœ˜Kšœ˜Kšœ˜Kšœ˜K˜—šžœ˜#Kšœ˜Kšœœœ ˜Kšœ˜Kšœ œ œ˜ Kšœ&˜&Kš œœœœ œ˜5Kšœœœœ˜˜>šœœ˜šœœ˜*M™3Mšœ ˜Mšœ˜—Mšœ.œ˜6Mšœœ˜—Mšœ˜Mšœ˜Mšœ˜Mšœ˜Mšœ˜Mšœ˜K˜—Kšœ8˜8Kšœœ˜5Kšœ#œœ˜-KšœC˜Išž œ™ Kšœœœ™Mšœ1™1Mšœ™—Mšœ"™"Kšœ˜K˜—šžœ˜!Kšœ˜Kšœœœ ˜Kšœ7˜7M™Mšœœ ˜Mšœœ ˜Kšœ˜Kšœ˜Kšœ˜Kšœœ ˜šž œ™Kšœœœ™Mšœ0™0Mšœ™—Mšœ!™!Kšœ˜——šŸ™šžœ˜Kšœ˜Kšœœœ ˜šž œ˜Kšœœœ˜Kšœ%œ ˜7Kšœ9™9Kšœœ™