<> <> <> <> <> DIRECTORY BasicTime USING [GMT, nullGMT], BcdDefs USING [VersionStamp], Rope USING [ROPE]; VersionMap: CEDAR DEFINITIONS = BEGIN OPEN BasicTime, BcdDefs, Rope; Map: TYPE = REF MapRep; MapList: TYPE = LIST OF Map; MapRep: TYPE = PRIVATE RECORD [ names: ROPE _ NIL, <> shortNameSeq: ShortNameSeq _ NIL, <> entries: SEQUENCE len: CARDINAL OF MapEntry]; <> MapEntry: TYPE = RECORD [ stamp: MyStamp _ nullStamp, -- the version stamp for the named file created: GMT _ nullGMT, -- create time of the file index: INT _ 0 -- position of the first char in the long name ]; MyStamp: TYPE = MACHINE DEPENDENT RECORD [lo,num,hi: CARDINAL]; nullStamp: MyStamp = [0, 0, 0]; <> ShortNameSeq: TYPE = REF ShortNameSeqRep; ShortNameSeqRep: TYPE = PRIVATE RECORD [SEQUENCE len: CARDINAL OF CARDINAL]; MapAndName: TYPE = RECORD [map: Map, name: ROPE, created: GMT]; MapAndNameList: TYPE = LIST OF MapAndName; Range: TYPE = RECORD [map: Map, first: CARDINAL, len: NAT]; <= the given short name (using the standard Rope.Compare without case). Also, len gives the number of short names that are equal to the short name. However, if len = 0, first may not be a legal index into shortNameSeq if the given shortName is >= to all of the names in the version map.>> RangeList: TYPE = LIST OF Range; <> VersionToName: PROC [list: MapList, stamp: BcdDefs.VersionStamp] RETURNS [MapAndName]; <<... returns a full path name (FS format) for the given version stamp. The list of maps is searched in order. For convenience on a match, the containing map is also returned. If the stamp is not found, [NIL, NIL] is returned.>> VersionToAllNames: PROC [list: MapList, stamp: VersionStamp] RETURNS [MapAndNameList]; <<... returns all of the full path names (FS format) for the given version stamp. The list of maps is searched in order. For convenience on a match, the containing map is also returned. If the stamp is not found, [NIL, NIL] is returned.>> ShortName: PROC [longName: ROPE] RETURNS [ROPE]; <<... returns the short name for the given long name. This simply involves stripping off the directory and version information.>> ShortNameToNames: PROC [list: MapList, shortName: ROPE] RETURNS [MapAndNameList]; <<... returns all of the full path names (FS format) for the given short name. The list of maps is searched in order. For convenience on a match, the containing map is also returned. If the stamp is not found, NIL is returned.>> ShortNameToRanges: PROC [list: MapList, shortName: ROPE] RETURNS [RangeList]; <<... returns all of the ranges that correspond to the given short name (see the comments for Range).>> GetPrefix: PROC [map: Map] RETURNS [ROPE]; <<... returns the prefix for file names in the map. Uses FS format ("[host]").>> StampToHex: PROC [stamp: VersionStamp] RETURNS [ROPE]; <<... returns the hex string for the version stamp. Uses standard hex format (0123456789ABCDEF).>> SaveMapToFile: PROC [map: Map, name: ROPE]; <<... saves a map in quickly machine-readable form.>> RestoreMapFromFile: PROC [name: ROPE, assumeImmutable: BOOL _ TRUE] RETURNS [map: Map]; <<... restores a map from a file written by SaveMapToFile. If assumeImmutable, then the named file is assumed to not change (this may avoid some copying and storage costs). >> FillInShortNames: PROC [map: Map]; <<... will create a shortNameSeq for version maps that do not have one. This is intended as an aid for external clients that would like to build version maps.>> Length: PROC [map: Map] RETURNS [INT]; <<... returns the # of entries in the map. >> Fetch: PROC [map: Map, index: CARDINAL] RETURNS [stamp: VersionStamp, name: ROPE, created: GMT]; <<... returns the name, stamp, and create date at the given index, where index IN [0..Length[map])>> FetchCreated: PROC [map: Map, index: CARDINAL] RETURNS [created: GMT]; <> FetchStamp: PROC [map: Map, index: CARDINAL] RETURNS [stamp: VersionStamp]; <> FetchName: PROC [map: Map, index: CARDINAL] RETURNS [name: ROPE]; <<... returns the name at the given index, where index IN [0..Length[map])>> RangeToEntry: PROC [range: Range] RETURNS [name: ROPE, stamp: VersionStamp, created: GMT, next: Range]; <<... returns the name and stamp for the first entry in the range, also returning the next range. If an empty range is given, the name returned will be NIL, and the range returned will be empty.>> <<>> END.