-- DirectoryDefs.Mesa  Edited by Johnsson on June 30, 1980  4:50 PM
-- Copyright  Xerox Corporation 1979, 1980

DIRECTORY
  AltoFileDefs USING [DV, FP],
  SegmentDefs USING [AccessOptions, FileHandle],
  StreamDefs USING [DiskHandle],
  StreamScan USING [Handle],
  StringDefs USING [BcplSTRING];

DirectoryDefs: DEFINITIONS =
  BEGIN OPEN StreamDefs, AltoFileDefs;

  -- Data structures

  DE: TYPE = MACHINE DEPENDENT RECORD [
    dv: AltoFileDefs.DV, name: StringDefs.BcplSTRING];

  DEptr: TYPE = POINTER TO DE;

  -- Signals

  BadFilename: ERROR [name: STRING];
  BadDirectory: ERROR;

  -- procedures that operate on standard directory


  EnumerateDirectory: PROCEDURE [
    proc: PROCEDURE [POINTER TO FP, STRING] RETURNS [BOOLEAN]];
  DirectoryLookup: PROCEDURE [fp: POINTER TO FP, name: STRING, create: BOOLEAN]
    RETURNS [old: BOOLEAN];
  DirectoryLookupFP: PROCEDURE [fp: POINTER TO FP, name: STRING]
    RETURNS [old: BOOLEAN];
  DirectoryPurge: PROCEDURE [fp: POINTER TO FP, name: STRING]
    RETURNS [found: BOOLEAN];
  DirectoryPurgeFP: PROCEDURE [fp: POINTER TO FP] RETURNS [found: BOOLEAN];

  -- Routines that operate on any directory


  Enumerate: PROCEDURE [
    dir: DiskHandle, proc: PROCEDURE [POINTER TO FP, STRING] RETURNS [BOOLEAN]];
  EnumerateEntries: PROCEDURE [
    dir: DiskHandle,
    proc: PROCEDURE [CARDINAL, StreamScan.Handle, DEptr] RETURNS [BOOLEAN],
    inspectFree: POINTER TO READONLY BOOLEAN, lengthFilter: CARDINAL ← 0]
    RETURNS [index: CARDINAL];
  Insert: PROCEDURE [dir: DiskHandle, fp: POINTER TO FP, name: STRING]
    RETURNS [old: BOOLEAN];
  Lookup: PROCEDURE [
    dir: DiskHandle, fp: POINTER TO FP, name: STRING, create: BOOLEAN]
    RETURNS [old: BOOLEAN];
  LookupFP: PROCEDURE [dir: DiskHandle, fp: POINTER TO FP, name: STRING]
    RETURNS [old: BOOLEAN];
  Purge: PROCEDURE [dir: DiskHandle, fp: POINTER TO FP, name: STRING]
    RETURNS [found: BOOLEAN];
  PurgeFP: PROCEDURE [dir: DiskHandle, fp: POINTER TO FP]
    RETURNS [found: BOOLEAN];

  ParseFileName: PROCEDURE [
    name, filename: STRING, dirAccess: SegmentDefs.AccessOptions]
    RETURNS [DiskHandle];

  SetWorkingDir: PROCEDURE [dir: SegmentDefs.FileHandle];
  GetWorkingDir: PROCEDURE RETURNS [dir: SegmentDefs.FileHandle];

  END.