blob: efd21c694d9dccb85c7b8c2478d45506854a133d [file] [log] [blame]
(* PathName.def maintains a dictionary of named paths.
Copyright (C) 2001-2023 Free Software Foundation, Inc.
Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
This file is part of GNU Modula-2.
GNU Modula-2 is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GNU Modula-2 is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Modula-2; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. *)
DEFINITION MODULE PathName ;
FROM DynamicStrings IMPORT String ;
FROM DynamicPath IMPORT PathList ;
TYPE
NamedPath ;
(*
FindNamedPathFile - returns NIL if a file cannot be found otherwise
it returns the path including the filename.
It also returns the name of the path.
*)
PROCEDURE FindNamedPathFile (filename: String; VAR name: String) : String ;
(*
AddInclude - adds include path to the named path. If named path
is the same as the previous call then the include path
is appended to the named path PathList otherwise a new
named path is created and placed at the end of the
named path list.
However if named is NIL or empty string then this is treated
as a user path and it will be appended to the first user
named list entry. The user entry will always be the
first node in the dictionary of named paths.
*)
PROCEDURE AddInclude (named, directory: String) ;
(*
InitNamedPath - creates a new path name with an associated pathlist.
*)
PROCEDURE InitNamedPath (name: String; pl: PathList) : NamedPath ;
(*
KillNamedPath - places list np onto the freelist.
Postcondition: np will be NIL.
*)
PROCEDURE KillNamedPath (VAR np: NamedPath) ;
(*
Cons - appends pl to the end of a named path.
If np is NIL a new list is created and returned
containing named and pl.
*)
PROCEDURE Cons (np: NamedPath; named: String; pl: PathList) : NamedPath ;
(*
ConsList - concatenates named path left and right together.
*)
PROCEDURE ConsList (left, right: NamedPath) : NamedPath ;
(*
Stash - returns np before setting np to NIL.
*)
PROCEDURE Stash (VAR np: NamedPath) : NamedPath ;
(*
SetNamedPath - assigns the named path to the default path.
*)
PROCEDURE SetNamedPath (named: NamedPath) ;
(*
GetNamedPath - returns the default named path.
*)
PROCEDURE GetNamedPath () : NamedPath ;
(*
DumpPathName - display the dictionary of names and all path entries.
*)
PROCEDURE DumpPathName (name: ARRAY OF CHAR) ;
END PathName.