| 1 |
DEFINITION MODULE PathName ; |
| 2 |
|
| 3 |
(* |
| 4 |
Title : PathName |
| 5 |
Author : Gaius Mulley |
| 6 |
System : GNU Modula-2 |
| 7 |
Date : Wed Feb 8 09:59:46 2023 |
| 8 |
Revision : $Version$ |
| 9 |
Description: maintains a dictionary of named paths. |
| 10 |
*) |
| 11 |
|
| 12 |
FROM DynamicStrings IMPORT String ; |
| 13 |
FROM DynamicPath IMPORT PathList ; |
| 14 |
|
| 15 |
|
| 16 |
TYPE |
| 17 |
NamedPath ; |
| 18 |
|
| 19 |
|
| 20 |
(* |
| 21 |
FindNamedPathFile - returns NIL if a file cannot be found otherwise |
| 22 |
it returns the path including the filename. |
| 23 |
It also returns the name of the path. |
| 24 |
*) |
| 25 |
|
| 26 |
PROCEDURE FindNamedPathFile (filename: String; VAR name: String) : String ; |
| 27 |
|
| 28 |
|
| 29 |
(* |
| 30 |
AddInclude - adds include path to the named path. If named path |
| 31 |
is the same as the previous call then the include path |
| 32 |
is appended to the named path PathList otherwise a new |
| 33 |
named path is created and placed at the end of the |
| 34 |
named path list. |
| 35 |
|
| 36 |
However if named is NIL or empty string then this is treated |
| 37 |
as a user path and it will be appended to the first user |
| 38 |
named list entry. The user entry will always be the |
| 39 |
first node in the dictionary of named paths. |
| 40 |
*) |
| 41 |
|
| 42 |
PROCEDURE AddInclude (named, directory: String) ; |
| 43 |
|
| 44 |
|
| 45 |
(* |
| 46 |
InitNamedPath - creates a new path name with an associated pathlist. |
| 47 |
*) |
| 48 |
|
| 49 |
PROCEDURE InitNamedPath (name: String; pl: PathList) : NamedPath ; |
| 50 |
|
| 51 |
|
| 52 |
(* |
| 53 |
KillNamedPath - places list np onto the freelist. |
| 54 |
Postcondition: np will be NIL. |
| 55 |
*) |
| 56 |
|
| 57 |
PROCEDURE KillNamedPath (VAR np: NamedPath) ; |
| 58 |
|
| 59 |
|
| 60 |
(* |
| 61 |
Cons - appends pl to the end of a named path. |
| 62 |
If np is NIL a new list is created and returned |
| 63 |
containing named and pl. |
| 64 |
*) |
| 65 |
|
| 66 |
PROCEDURE Cons (np: NamedPath; named: String; pl: PathList) : NamedPath ; |
| 67 |
|
| 68 |
|
| 69 |
(* |
| 70 |
ConsList - concatenates named path left and right together. |
| 71 |
*) |
| 72 |
|
| 73 |
PROCEDURE ConsList (left, right: NamedPath) : NamedPath ; |
| 74 |
|
| 75 |
|
| 76 |
(* |
| 77 |
Stash - returns np before setting np to NIL. |
| 78 |
*) |
| 79 |
|
| 80 |
PROCEDURE Stash (VAR np: NamedPath) : NamedPath ; |
| 81 |
|
| 82 |
|
| 83 |
(* |
| 84 |
SetNamedPath - assigns the named path to the default path. |
| 85 |
*) |
| 86 |
|
| 87 |
PROCEDURE SetNamedPath (named: NamedPath) ; |
| 88 |
|
| 89 |
|
| 90 |
(* |
| 91 |
GetNamedPath - returns the default named path. |
| 92 |
*) |
| 93 |
|
| 94 |
PROCEDURE GetNamedPath () : NamedPath ; |
| 95 |
|
| 96 |
|
| 97 |
(* |
| 98 |
DumpPathName - display the dictionary of names and all path entries. |
| 99 |
*) |
| 100 |
|
| 101 |
PROCEDURE DumpPathName (name: ARRAY OF CHAR) ; |
| 102 |
|
| 103 |
|
| 104 |
END PathName. |