VersionMapBuilder.mesa
Russ Atkinson, January 31, 1983 5:39 pm
Support for version stamp to long file name mapping.
DIRECTORY
Rope USING [ROPE],
TimeStamp USING [Stamp],
VersionMap USING [Map];
VersionMapBuilder: CEDAR DEFINITIONS
= BEGIN OPEN Rope, VersionMap;
Signals & errors
VersionNotAvailable: ERROR;
NameError: ERROR;
DuplicateVersionSignal: SIGNAL;
WriteMapToFile: PROC
[map: Map, name: ROPE, checkForDuplicateVersions: BOOLFALSE];
Writes a map in human-readable form. If checkForDuplicateVersions, then a check will be made for duplicate versions as the file is being written. Duplicates with the same short name will be discarded, and duplicates with different short names will cause DuplicateVersionSignal to be raised. RESUMEing will retain the duplicate. This procedure has very little allocation in it.
ParseMapFromFile: PROC [name: ROPE] RETURNS [map: Map];
ParseMapFromFile reads a file written by WriteMapToFile. The first line has the prefix for the map, and succeeding lines have the version stamp in hex followed by the long path name. An empty line after the first line terminates the file as far as ParseMapFromFile is concerned. One very useful feature of ParseMapFromFile is that the entries DO NOT have to be sorted in version stamp order.
MergeMaps: PROC
[map1,map2: VersionMap.Map] RETURNS [map: VersionMap.Map];
MergeMaps[map1,map2] takes the two given maps and merges them into one. There is no checking for duplicate entries, and certainly no discarding of same. The names rope for the resulting map is roughly the concatenation of the two maps. The merging of names favors the prefix given by map1.
DistributePrefix: PROC
[map: VersionMap.Map] RETURNS [newMap: VersionMap.Map];
-- DistributePrefix[map] takes a version map and expands all of the prefixes in it. This is good preparation for merging version maps, of course. The resulting map will be the initial map if all of the entries have explicit prefixes. The resulting map will have a prefix stored in the names, incidentally.
SplitMap: PROC
[map: VersionMap.Map] RETURNS [symbols,source: VersionMap.Map];
SplitMap[map] splits a version map into maps for symbols and source. The names rope is shared between both the input map and the two resulting maps, which is much more efficient, but may hold on to some rather large ropes. The algorithm takes two passes through the map: first, to determine the respective resulting sizes, and second, to create the new maps.
CompressMap: PROC
[map: VersionMap.Map] RETURNS [newMap: VersionMap.Map];
CompressMap[map] compresses a version map, discarding unused portions from the names. We also make a half-hearted attempt to factor out the first prefix we see from the rest of the names (we should be able to do better). The algorithm takes 1 pass to find a prefix if the map does not initially have one (stops at first prefix found), 1 pass to determine the length of the resulting names rope, and 1 potentially random-access pass to create the new names rope.
SetReportInterval: PROC [seconds: NAT ← 0];
SetReportInterval sets the interval between reports of progress to the message window. These reports are made by GenerateMapFromRemote and other long-winded procedures. If the interval is 0, then no reporting is performed.
GenerateMapFromRemote: PROC
[host: ROPENIL, directory: ROPENIL, oldMap: Map ← NIL, filter: FilterProc ← NIL]
RETURNS [map: Map];
GenerateMapFromRemote generates a map from a host (e.g. "Indigo") and a file pattern name (e.g. "<Cedar>*.bcd"). This procedure requires an exporter of IFSFile. If oldMap # NIL, then merge with old version map (entries with full names in the old version map will get the version stamp from the old map, which reduces.
GenerateMapFromDFFile: PROC
[name: ROPENIL, pattern: ROPENIL, oldMap: Map ← NIL, filter: FilterProc ← NIL]
RETURNS [map: Map];
GenerateMapFromDFFile generates a map from a DF file (and filter pattern, like "*.bcd"). This procedure requires an exporter of DFUser. If oldMap # NIL, then merge with old version map.
GenerateMapFromProc: PROC
[each: EachProc, data: REFNIL, prefix: ROPENIL] RETURNS [map: Map];
GenerateMapFromProc a map from user-supplied entries. The data argument is passed through to EachProc for the user's convenience.
EachProc: TYPE = PROC [data: REF] RETURNS [stamp: TimeStamp.Stamp, name: ROPE];
EachProc is the type of the user-supplied procedure used to generate each entry in the map. Return name = NIL to terminate generation.
FilterProc: TYPE = PROC [name: ROPE] RETURNS [ok: BOOL];
FilterProc is the type of user-supplied filter on file names. Return TRUE to use name, FALSE to skip .it
NonBCDFilter: FilterProc;
filters out BCDs
OnlyBCDFilter: FilterProc;
filters in BCDs only
END.