DIRECTORY AlpineDirectory USING [Version, highest, all], AlpineEnvironment, AlpTransaction USING [Handle], BTree USING [PathStk, Tree], BTreeAlpineVM USING [Handle], Rope USING [ROPE, Text]; AlpineDirectoryBTree: CEDAR DEFINITIONS = BEGIN OPEN AD: AlpineDirectory, AE: AlpineEnvironment; EntryHandle: TYPE = REF EntryRecord; EntryRecord: TYPE = RECORD[ found: BOOL _ FALSE, -- whether or not the entry exists name: Rope.ROPE _ NIL, -- path name passed in by client volume: Rope.Text _ NIL, -- the name of the volume group owner: Rope.Text _ NIL, -- the name of the owner nameBody: Rope.Text _ NIL, -- subdirectories and filename; no version desiredVersion: AD.Version _ 0, -- version in the name (includes highest, lowest, and all) pattern: Rope.ROPE _ NIL, -- pattern used for enumerations pVolume: Rope.Text _ NIL, -- pattern volume name pOwner: Rope.Text _ NIL, -- pattern owner name pNameBody: Rope.Text _ NIL, -- pattern nameBody pVersion: AD.Version _ 0, -- pattern version (includes highest, lowest, and all) trans: AlpTransaction.Handle, volGroupID: AE.VolumeGroupID _ AE.nullVolumeGroupID, btree: TreeRecord _ [], -- btree and backing storage pathStk: BTree.PathStk _ NIL, -- a hint to the btree usePathStk: BOOL _ FALSE, -- a hint to the btree directory: BOOL _ FALSE, -- this is the entry for the directory btree file: AE.UniversalFile _ AE.nullUniversalFile, -- actual file link: Rope.Text _ NIL, -- actual link version: AD.Version _ 0, -- actual version keep: CARDINAL _ 0, -- actual keep inUse: EntryHandle _ NIL, -- inUse = NIL => this handle is being used recentlyInUse: BOOL _ FALSE -- one bit LRU marker ]; TreeRecord: TYPE = RECORD[ tree: BTree.Tree _ NIL, storage: BTreeAlpineVM.Handle _ NIL]; -- the backing storage for the btree ReadEntry: PROC [trans: AlpTransaction.Handle, name: Rope.ROPE, defaultVersion: AD.Version _ AD.highest, desiredVersion: AD.Version _ AD.all] RETURNS [entry: EntryHandle]; NextEntry: PROC [trans: AlpTransaction.Handle, pattern, start: Rope.ROPE, defaultVersion: AD.Version _ AD.all] RETURNS [entry: EntryHandle]; WriteEntry: PROC [entry: EntryHandle]; DeleteEntry: PROC [entry: EntryHandle]; GetDirectory: PROC [trans: AlpTransaction.Handle, volume: Rope.ROPE, owner: AE.OwnerName] RETURNS [directory: AE.UniversalFile]; FreeEntryHandle: PROC [entry: EntryHandle]; FullPathName: PROC [entry: EntryHandle] RETURNS[name: Rope.ROPE]; END. @AlpineDirectoryBTree.mesa Last Edited by: Maxwell, November 23, 1983 9:28 am Each entry in the BTree consists of a nameBody, a version, a file or a link, and a keep. The nameBody consists of the sub-directorys and file name; it does not include the volume group name, server, or version number. All version parameters conform to AlpineDirectory.Version. The link may or may not include an explicit version number. This interface deals mostly with EntryHandles. An EntryHandle contains a copy of the information found in a BTree entry. The suggest style is to use ReadEntry to obtain an entry, modify the parameters in the handle, and then use WriteEntry to put the changes back into the BTree. When you are through with the handle, free it with FreeEntryHandle. A subsequent call may reuse the handle and whatever state that is still valid. Alpine guarantees atomicity between accesses in different transactions, and there are reader/writer locks in the BTree handle for concurrent accesses within a single transaction. This package guarantees that there is at most one BTree handle in use per BTree per transaction. (There may be more than one entry handle, but they will all use the same BTree handle.) ! Error {illegalFileName, damagedDirectory} plus errors that might be generated from AlpineOwner.ReadProperties, AlpineFile.Open, AlpineFile.Create, AlpineFile.WriteProperties, and AlpineOwner.WriteProperties. Parses the name, opens the btree and constructs an entry handle for the information there. If there is no version in the name then defaultVersion is used. If desiredVersion is highest or lowest then it will override the version given in name. ! Error {illegalFileName, illegalPattern, damagedDirectory} plus errors that generated from AlpineOwner.ReadNext, AlpineOwner.ReadProperties, AlpineFile.Open, AlpineFile.Create, AlpineFile.WriteProperties, and AlpineOwner.WriteProperties. Gets the entry for start and then enumerates until an entry matching pattern is found. defaultVersion is the version used if pattern doesn't have a version on it. ! Error {damagedDirectory}. Writes the information stored in the handle into the BTree. ! Error {damagedDirectory}. Removes the entry from the BTree. ! Errors generated by AlpineOwner.ReadProperties. Allows the handle to be reused. It isn't a disaster if entry handles aren't freed. Ê[– "cedar" style˜Jšœ™J™2J™šÏk ˜ Jšœœ˜.Jšœ˜Jšœœ ˜Jšœœ˜Jšœœ ˜Jšœœœ˜—J˜šÐblœ˜/JšœÓ™ÓJšœ®™®Jšœï™ïJ™J™Jšœ,˜0—J˜J˜šœ œœ ˜$šœ œœ˜JšœœœÏc"˜7Jšœ œœŸ ˜7JšœœŸ˜8JšœœŸ˜0JšœœŸ*˜EJšœ Ÿ:˜ZJšœœœŸ ˜:JšœœŸ˜0JšœœŸ˜.JšœœŸ˜/JšœŸ6˜PJšœ˜Jšœ4˜4JšœŸ˜5JšœœŸ˜4Jšœ œœŸ˜0Jšœ œœŸ,˜EJšœ/Ÿ˜=JšœœŸ˜%JšœŸ˜*JšœœŸ˜"JšœœŸÏiŸ"˜EJšœœœŸ˜1Jšœ˜—šœ œœ˜Jšœœ˜Jšœ œŸ$˜J——J˜šÏn œœ˜Jšœ*œP˜~Jšœ˜JšœÑ™ÑJ™ZJ™?JšœW™W—J™š¡ œ˜Jšœ4œ&˜^Jšœ˜Jšœî™îJ™VJšœK™K—J™š¡ œœ˜Jšœ˜J™J™;—J˜š¡ œ˜Jšœ˜J™J™!—J˜š¡ œ˜Jšœ,œ˜GJšœ˜&Jšœ1™1—J˜š¡œ˜Jšœ˜J™S—J™š¡ œ˜Jšœ˜Jšœ œ˜—J˜Jšœ˜J˜—…— dÿ