DFClosure.mesa
Copyright Ó 1986, 1987, 1991 by Xerox Corporation. All rights reserved.
Adapted by Bertrand Serlet from GenerateDFClosure by Russ Atkinson June 25, 1985
Bertrand Serlet February 27, 1987 8:50:38 pm PST
Mike Spreitzer January 22, 1987 1:39:07 pm PST
DIRECTORY
DFUtilities USING [Date, UsingForm],
Rope USING [ROPE];
DFClosure: CEDAR DEFINITIONS = BEGIN
Types
Date: TYPE = DFUtilities.Date;
UsingForm: TYPE = DFUtilities.UsingForm;
ROPE: TYPE = Rope.ROPE;
FileProc: TYPE = PROC [data: REF, name: ROPE, date: Date, from: ROPE, exported: BOOL];
When using EnumerateClosure, the user's action procedure is called for every file in the DF closure.
data is as given to EnumerateClosure
name is the full name of the file as given by the DF file
date is the creation date of the file as given in the parent DF file
from is the name of the parent DF file
exported indicates whether or not this file is exported by its containing df file
ImportProc: TYPE = PROC [data: REF, dfName: ROPE, date: Date, exported: BOOL, form: UsingForm] RETURNS [recursionKind: RecursionKind ¬ same];
When using EnumerateClosure, the user's action procedure is called for every import in the DF closure.
data is as given to EnumerateClosure
dfName is the full name of the file as given by the DF file
date is the creation date of the file as given in the parent DF file
form is the UsingForm as given in the parent DF file
recurse determines whether closure includes Imported items
RecursionKind: TYPE = {none, public, all, same};
none if import should not be chased recursively
public if only defined files should be added in the closure
all if all files should be added in the closure
same if current recursionKind should be used
MessageProc: TYPE = PROC [data: REF, message: ROPE];
Called to report progress messages.
data is as given to EnumerateClosure
ErrorProc: TYPE = PROC [data: REF, kind: ErrorKind, message: ROPE];
When using EnumerateClosure, the user's error procedure is called for every error.
data is as given to EnumerateClosure
ErrorKind: TYPE = {notFound, syntaxError, aborted};
notFound for a DF file that was not found
syntaxError for a DF file with a syntax error
aborted if user requested abortion
Operations
EnumerateClosure: PROC [dfName: ROPE, private: BOOL, file: FileProc, import: ImportProc, error: ErrorProc, message: MessageProc ¬ NIL, data: REF ¬ NIL] RETURNS [dfFiles: INT];
Enumerates the closure of files mentioned by the given DF file. Files may appear in the closure twice, although this is not frequent for well-structured DF files.
If private then recursion is started with all, otherwise with public.
The information returned from EnumerateClosure indicates the number of DF files opened.
Utilities
When the file system is assumed not to change during several calls to DFUtilitiesExtras.ParseFromFile, the mapping between short path names and full path name in the bracket format (including a version number) can be cached. The following two functions provide efficient mapping. Mapping memory is recovered when references are dropped.
CreateShortToFullMapping: PROC RETURNS [mapping: REF];
ShortToFullMapping: PROC [mapping: REF, short: ROPE] RETURNS [full: ROPE];
mapping is a cache created by CreateShortToFullMapping.
May raise FS.ERROR.
END.