home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / modu1096.zip / GPMsym / gpfiles.def < prev    next >
Text File  |  1996-08-29  |  4KB  |  92 lines

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