GPFILES.DEF 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. (****************************************************************)
  2. (* *)
  3. (* Gardens Point Compiler Source Module *)
  4. (* *)
  5. (* File name lookup and create *)
  6. (* *)
  7. (* (c) copyright 1992 Faculty of Information Technology. *)
  8. (* This module may be used freely for the construction *)
  9. (* of tools which interwork with gardens point compilers *)
  10. (* *)
  11. (* original module : kjg July 1992 *)
  12. (* modifications : kjg Sep 1992 lowercase default, use *)
  13. (* GPNAMES=MIXED for mixed case... *)
  14. (* *)
  15. (****************************************************************)
  16. DEFINITION MODULE GpFiles;
  17. FROM UxFiles IMPORT File;
  18. (*
  19. * this module implements the gpm file lookup strategy.
  20. * It was introduced to make the change from lower case
  21. * to mixed case file names in a consistent manner for
  22. * gpm, build, gpmake, gpscript, decode, mkenumio and
  23. * other tools which lookup files based on module names.
  24. * The lookup strategy is backward compatible with the
  25. * filenames created by previous version of gpm.
  26. *
  27. * GPNAMES=MIXED GPNAMES=LOWER
  28. * lookup(1) name as given; lookup(1) lower case;
  29. * lookup(2) lower case; lookup(2) name as given;
  30. * lookup(3) DOS length; lookup(3) DOS length;
  31. *)
  32. CONST fileNameLength = 79; (* max base name length *)
  33. oldFileNameLength = 8; (* DOS compatibility *)
  34. PROCEDURE GpCreateFile( base : ARRAY OF CHAR;
  35. ext : ARRAY OF CHAR;
  36. VAR name : ARRAY OF CHAR;
  37. VAR file : File); (* NIL if can't create *)
  38. (* Truncate base name at fileNameLength. *)
  39. (* If ext <> "" then a dot and the ext are *)
  40. (* appended, otherwise the base unchanged. *)
  41. (* Name is then made lower case unless the *)
  42. (* env variable GPNAMES has first character *)
  43. (* "m" or "M" at module initialization time *)
  44. (* post : name is the name of the created file *)
  45. PROCEDURE GpFilename( base : ARRAY OF CHAR;
  46. ext : ARRAY OF CHAR;
  47. VAR name : ARRAY OF CHAR);
  48. (* Truncate base name at fileNameLength. *)
  49. (* If ext <> "" then a dot and the ext are *)
  50. (* appended, otherwise the base unchanged. *)
  51. (* Name is then made lower case unless the *)
  52. (* env variable GPNAMES has first character *)
  53. (* "m" or "M" at module initialization time *)
  54. (* post : name is the name of the created file *)
  55. PROCEDURE GpFindLocal( base : ARRAY OF CHAR;
  56. ext : ARRAY OF CHAR;
  57. VAR name : ARRAY OF CHAR;
  58. VAR file : File); (* or NIL if not found *)
  59. (* Look for file in current directory ... *)
  60. (* If ext <> "" then look for "base.ext", *)
  61. (* else look for the file "base" *)
  62. (* post : name is the name of the file, if found in *)
  63. (* the current directory, else file = NIL *)
  64. PROCEDURE GpFindOnPath( path : ARRAY OF CHAR;
  65. base : ARRAY OF CHAR;
  66. ext : ARRAY OF CHAR;
  67. VAR name : ARRAY OF CHAR;
  68. VAR file : File); (* or NIL if not found *)
  69. (* Look for file first in current directory, *)
  70. (* then on the given path. *)
  71. (* If ext <> "" then look for "base.ext", *)
  72. (* else look for the file "base" *)
  73. (* Actual "name" must be long enough for the *)
  74. (* longest possible path name! *)
  75. (* post : name is the pathname of the file, if *)
  76. (* file found, else file = NIL *)
  77. END GpFiles.