-- CS.mesa
-- last edit by Schmidt, July 1, 1982 11:29 am
-- last edit by Satterthwaite, August 11, 1983 8:23 am
-- replacement for Subr.mesa in the Cedar world

DIRECTORY
  File: TYPE USING [Capability, delete, grow, Permissions, read, shrink, write],
  IO: TYPE USING [STREAM],
  Rope: TYPE USING [ROPE, Text],
  Stream: TYPE USING [Handle],
  TimeStamp: TYPE USING [Stamp];
	
CS: CEDAR DEFINITIONS ~ {

 -- variables
  z: ZONE;	-- use this zone to allocate all REF's

 -- signals
  FileErrorType: TYPE ~ {notFound, wrongVersion};
  FileError: ERROR[error: FileErrorType];

 -- CONSTANTS
  read: File.Permissions ~ File.read;
  write: File.Permissions ~ File.write+File.grow+File.shrink+File.delete;
  readWrite: File.Permissions ~ read+write;

 -- call this to make sure module is started
  Init: PROC;

 -- rope utilities
  RopeToString: UNSAFE PROC[to: LONG STRING, from: Rope.ROPE];
  RootName: PROC[name: Rope.ROPE] RETURNS[root: Rope.ROPE];
  EndsIn: PROC[str: Rope.ROPE, suf: Rope.Text] RETURNS[BOOL];
  EqualRS: PROC[r: Rope.ROPE, s: LONG STRING] RETURNS[equal: BOOL];
  EquivalentRS: PROC[r: Rope.ROPE, s: LONG STRING] RETURNS[equivalent: BOOL];
  StringToRope: UNSAFE PROC[from: LONG STRING] RETURNS[Rope.ROPE];
  
  CardFromRope: PROC[r: Rope.ROPE] RETURNS[val: LONG CARDINAL];
  RopeFromCard: PROC[val: LONG CARDINAL] RETURNS[Rope.ROPE];
  StampFromRope: PROC[r: Rope.ROPE] RETURNS[TimeStamp.Stamp];
  RopeFromStamp: PROC[stamp: TimeStamp.Stamp] RETURNS[Rope.ROPE];

 -- other
  Confirm: PROC[dch: CHAR, in, out: IO.STREAM] RETURNS[CHAR];

  NewStream: UNSAFE PROC[name: Rope.Text, access: File.Permissions] 
	RETURNS[Stream.Handle];

 -- npages should not include the leader page;  I'll add +1
  NewFile: UNSAFE PROC[name: Rope.Text, access: File.Permissions, npages: NAT]
	RETURNS[File.Capability];

 -- iostream utilities
  SetPFCodes: PROC[h: IO.STREAM];

  }.