DEFINITION MODULE FileNames;
(*$ LargeVars:=FALSE NameChk:=FALSE *)
(* 2.1 / 29.5.87 / ms *)

FROM SYSTEM IMPORT CAST;

TYPE
 ReadProc=PROCEDURE(VAR CHAR);
 WriteProc=PROCEDURE(CHAR);

CONST
 noEcho=CAST(WriteProc,NIL);
(*
 * ReadFileName reads a filename using the supplied I/O
 * routines. Read should not echo, Write should interpret
 * <bs> and <del> as erasing the last character. len
 * gives the number of characters in the filename. If the
 * user hits <esc> the filename is returned empty with
 * len=0. <cr> is ignored on an empty input else it
 * terminates the string. All characters
 * [" "..CHAR(del-1)] are accepted.
 *
 * ReadFileName(fname,len,Terminal.Read,Terminal.Write);
 *	user: df1:exec/Alerts.sym<cr>
 *	fname="df1:exec/sym/Alerts.sym"; len=23;
 *)
PROCEDURE ReadFileName(
            VAR fname: ARRAY OF CHAR; VAR len: INTEGER;
            readProc: ReadProc; writeProc: WriteProc);
(*
 * GetPath removes the path info in fname and stores it
 * in path. len is asssumed to hold the lenght of fname
 * and is set according the new length of fname.
 *
 * GetPath(fname, path, len);
 * 	fname="Alerts.sym"; len=10;
 *	path ="df1:exec/sym/";
 *)
PROCEDURE GetPath(
            VAR fname, path: ARRAY OF CHAR;
            VAR len: INTEGER);

(*
 * GetExtension works as GetPath except that it removes
 * any extension from the filename. An extension is
 * assumed to be separated by a dot.
 *)
PROCEDURE GetExtension(
            VAR fname, extension: ARRAY OF CHAR;
            VAR len: INTEGER);

(*
 * MakeFileName is a simple concat of the four strings.
 * It is useful to concat filenames.
 *
 * MakeFileName(
 *    fname, len, "df1:", "exec/sym/", "Alerts", ".sym")
 *	fname="df1:exec/sym/Alerts.sym"; len=23;
 *
 *)
PROCEDURE MakeFileName(
            VAR fname: ARRAY OF CHAR; VAR len: INTEGER;
            dev, dir, name, ext: ARRAY OF CHAR);

END FileNames.
