AMFilesImpl.mesa
Last Modified On December 12, 1983 10:57 am By Paul Rovner
DIRECTORY
AMFiles USING [],
BasicTime USING [GMT, nullGMT],
FS USING [OpenFile, FileInfo, Error, Open, nullOpenFile, GetDefaultWDir],
Rope USING [Fetch, ROPE];
=
BEGIN
OPEN Rope;
pathPrefixes: PUBLIC LIST OF ROPE ← CONS["///", NIL];
FullFileName:
PUBLIC
PROC
[shortName: ROPE, createTime: BasicTime.GMT ← BasicTime.nullGMT]
RETURNS[fullName: ROPE] = {
firstChar: CHAR = shortName.Fetch[0];
IF firstChar = '[ OR firstChar = '/ OR firstChar = '< THEN RETURN[shortName];
FOR paths:
LIST
OF
ROPE ← pathPrefixes, paths.rest
UNTIL paths =
NIL
DO
fullName
←
FS.FileInfo[name: shortName, wantedCreatedTime: createTime, wDir: paths.first
! FS.Error => {fullName ← NIL; CONTINUE}].fullFName;
IF fullName = NIL THEN LOOP;
RETURN[fullName];
ENDLOOP;
fullName
←
FS.FileInfo[name: shortName, wantedCreatedTime: createTime, wDir:
FS.GetDefaultWDir[]
! FS.Error => {fullName ← NIL; CONTINUE}].fullFName;
};
procedures for opening symbol and source files (for read)
OpenIt:
PUBLIC
PROC
[shortName: ROPE, createTime: BasicTime.GMT ← BasicTime.nullGMT]
RETURNS[fullName: ROPE ← NIL, openFile: FS.OpenFile ← FS.nullOpenFile] = {
fullName ← FullFileName[shortName, createTime];
IF fullName #
NIL
THEN openFile ← FS.Open[fullName ! FS.Error => {fullName ← NIL; CONTINUE}];
};
PrependPathPrefix:
PUBLIC
ENTRY
PROC[pathPrefix:
ROPE] = {
ENABLE
UNWIND =>
NULL;
pathPrefixes ← CONS[pathPrefix, pathPrefixes];
};