Page Numbers: Yes First Page: 9 X: 527 Y: 10.5" Margins: Binding: 13 Odd Heading: Not-on-first-pagex2qjk40(635) Alto/Mesa Directory Packagey756qck40\b27B Even Heading:x2qjk40 Alto/Mesa Directory Packagey756qck40\b27B Alto/Mesa Directory Package October 1980y684x12e12c\f5b28f0B The Mesa directory package provides a number of procedures to manipulate the standard Alto directory (SysDir) or any file which follows the format of the Alto directory (see DirectoryDefs). These routines also support sub-directories. This section depends heavily on the section on Files, and that section should be read before this. (See the Alto Operating System Reference Manual for file structure details.)x2e36j\102f8 6f0 67f6b13f7B3f0 95b5B57i38I Most of the operations described below come in pairs. The operation containing the word Directory operates on the standard Alto directory (SysDir). The other operation of the pair operates on the directory specified by the disk stream handle dir. (Note that a NIL DiskHandle does not imply the system directory).x2e12j\89f6b9f0B42f8 6f0 98f6b3f0B16f7b3f0B1f6b10f0B6i3I The simplest operation provided is to enumerate all of the file entries in the directory:x2e12j EnumerateDirectory: PROCEDURE [proc: PROCEDURE [POINTER TO FP, STRING] RETURNS [BOOLEAN]];z18697l3633d2999x2e12jk72\f6b20f7 9f6 8f7 9f6 2f7 7f6 1f7 2f6 5f7 6f6 2f7 7f6 2f7 7f6 Enumerate: PROCEDURE [ dir: DiskHandle, proc: PROCEDURE [POINTER TO FP, STRING] RETURNS [BOOLEAN]];z18697l3633d2999x2e12jk72\f6b11f7 9f6 26f7 9f6 2f7 7f6 1f7 2f6 5f7 6f6 2f7 7f6 2f7 7f6 Calls proc once for each filename in the directory, passing it pointers to the file's FP and name. Processing terminates when proc returns TRUE or the end of the directory is reached.l4269x2e12j\6f6b4f0B76f6b2f0B39f6b4f0B9f7b4f0B Fine point: these parameters are local to the enumeration procedure and must be copied if they are to be retained after the enumeration completes.l4269x2e6j\f1 A faster way to read a directory is to use the StreamScan facilities described in the Streams section of this document.x2e12j\47f6b10f0B29b7B EnumerateEntries: PROCEDURE [ dir: DiskHandle, proc: PROCEDURE [CARDINAL, StreamScan.Handle, DEptr] RETURNS [BOOLEAN], inspectFree: POINTER TO READONLY BOOLEAN, lengthFilter: CARDINAL _ 0] RETURNS [index: CARDINAL];z18697l4269x2e6k40(2116)\f6b18f7 9f6 30f7 9f6 2f7 8f6 28f7 7f6 2f7 7f6 18f7 27f6 18f7 8f6 6f7 7f6 9f7 8f6 The procedure proc is called for each directory entry; free entries are passed only if inspectFree^ is TRUE. If the lengthFilter is non-zero, only entries with a filename length equal to lengthFilter characters will be passed to proc.x2e6jk40\14f6b4f0B69f6b12f0B4f7 4f0 10f6b12f0B59f6b12f0B30f6b4f0B The following procedures may be of use to programmers implementing features beyond those provided by NewFile and DestroyFile.x2e12j(635)\101f6b7f0B5f6b11f0B DirectoryLookup: PROCEDURE [fp: POINTER TO FP, name: STRING, create: BOOLEAN] RETURNS [old: BOOLEAN];z18697l3633d2999x2e12jk108\f6b17f7 9f6 6f7 7f6 1f7 2f6 11f7 6f6 10f7 7f6 2f7 7f6 7f7 7f6 Lookup: PROCEDURE [ dir: DiskHandle, fp: POINTER TO FP, name: STRING, create: BOOLEAN] RETURNS [old: BOOLEAN];z18697l3633d2999x2e12jk72\f6b8f7 9f6 24f7 7f6 1f7 2f6 11f7 6f6 10f7 7f6 2f7 7f6 7f7 7f6 Looks up name in the directory. If an entry already exists, its file pointer is copied into fp and TRUE is returned, otherwise FALSE is returned. In addition, if create is TRUE, the file will be created (with one empty data page), and the new file pointer will be copied into fp.l4269x2e12j\9f6b4f0B80f6b2f0B5f7b4f0B24f7b5f0B31f6b6f0B4f7b4f0B100f6b2f0B BadFileName: ERROR [name: STRING];z18697l3633d2999x2e12jk72\f6b13f7 6f6 7f7 6f6 Raised if one tries to insert a directory entry for name, using one of several procedures in the interface, and the name is too long or contains invalid characters.l4269x2e12j\52f6b4f0B DirectoryLookupFP: PROCEDURE [fp: POINTER TO FP, name: STRING] RETURNS [old: BOOLEAN];z18697l3633d2999x2e12jk72\f6b19f7 9f6 6f7 7f6 1f7 2f6 11f7 6f6 2f7 7f6 7f7 7f6 LookupFP: PROCEDURE [dir: DiskHandle, fp: POINTER TO FP, name: STRING] RETURNS [old: BOOLEAN];z18697l3633d2999x2e12jk72\f6b10f7 9f6 23f7 7f6 1f7 2f6 11f7 6f6 2f7 7f6 7f7 7f6 Similar to DirectoryLookup, except that the directory is searched for a matching FP. It returns TRUE if the file pointer was found. In addition it will supply the filename if name is not NIL.l4269x2e12j\11f6b15f0B55f6b2f0B14f7b4f0B76f6b4f0B8f7b3f0B DirectoryPurge: PROCEDURE [fp: POINTER TO FP, name: STRING] RETURNS [found: BOOLEAN];z18697l3633d2999x2e12jk72\f6b16f7 9f6 6f7 7f6 1f7 2f6 11f7 6f6 2f7 7f6 9f7 7f6 Purge: PROCEDURE [dir: DiskHandle, fp: POINTER TO FP, name: STRING] RETURNS [found: BOOLEAN];z18697l3633d2999x2e12jk72\f6b7f7 9f6 23f7 7f6 1f7 2f6 11f7 6f6 2f7 7f6 9f7 7f6 Removes the entry corresponding to name from the directory (it does not disturb the file pages pointed to by the FP, however). If the file is found, its file pointer is copied into fp and TRUE is returned, otherwise FALSE is returned.l4269x2e12j\35f6b4f0B29i3I42f6b2f0B67f6b2f0B5f7b4f0B24f7b5f0B DirectoryPurgeFP: PROCEDURE [fp: POINTER TO FP] RETURNS [found: BOOLEAN];z18697l3633d2999x2e12jk72\f6b18f7 9f6 6f7 7f6 1f7 2f6 5f7 7f6 9f7 7f6 PurgeFP: PROCEDURE [dir: DiskHandle, fp: POINTER TO FP] RETURNS [found: BOOLEAN];z18697l3633d2999x2e12jk72\f6b9f7 9f6 23f7 7f6 1f7 2f6 5f7 7f6 9f7 7f6 Similar to DirectoryPurge, except that the directory is searched for a matching FP. It returns TRUE if the file pointer was found, deleting the entry in the process.l4269x2e12j\11f6b14f0B55f6b2f0B14f7b4f0B Insert: PROCEDURE [ dir: DiskHandle, fp: POINTER TO AltoFileDefs.FP, name: STRING] RETURNS [old: BOOLEAN];z18697l3633d2999x2e12jk72\f6b8f7 9f6 24f7 10f6 24f7 6f6 2f7 7f6 7f7 7f6 Inserts a directory entry with the specified name and fp; unlike Lookup, it does not create a file. If an entry with the same name is encounter it returns TRUE and the entry is unchanged, otherwise it returns FALSE.l4269x2e12j\45f6b4f0B5f6b2f0B10f6b6f0B85f7b4f0B50f7b5f0B ParseFileName: PROCEDURE [ name, filename: STRING, dirAccess: SegmentDefs.AccessOptions] RETURNS [StreamDefs.DiskHandle];z18697l3633d2999x2e12jk72\f6b15f7 9f6 19f7 6f6 40f7 7f6 Strips the leading directory information from name, puts the result in filename (appending a period if necessary), and returns a stream (with access dirAccess) open on the directory in which the file should be looked up.l4269x2e12j\46f6b4f0B21f6b8f0B70f6b9f0B The following procedures set and return the directory used for looking up files which do not specify a directory name (initially set to "