pathin.sl 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. %
  2. % PATHIN.SL - Rlisp IN function with a search path
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 26 July 1982
  9. % Copyright (c) 1982 University of Utah
  10. %
  11. % PATHIN(filename-tail:string):none EXPR
  12. %
  13. % PATHIN allows the use of a directory search path with the Rlisp IN function.
  14. % The fluid variable PATHIN* should be a list of strings, which are directory
  15. % names. These will be successively concatenated onto the front of the
  16. % string argument to PATHIN until an existing file is found. If one is found,
  17. % IN will be invoked on the file. If not, a continuable error occurs.
  18. % E.g, if PATHIN* is ("" "/usr/src/cmd/psl/" "/u/smith/"), (pathin "foo.red")
  19. % will attempt to open "foo.red", then "/usr/src/cmd/psl/foo.red", and finally
  20. % "/u/smith/foo.red".
  21. (bothtimes (fluid '(pathin*)))
  22. (compiletime (flag '(pathin-aux) 'internalfunction))
  23. (loadtime (flag '(pathin) 'ignore)) % just like IN, gets done while compiling
  24. (loadtime (if (null pathin*) (setq pathin* '(""))))
  25. % acts like IN until path is changed
  26. (de pathin (filename-tail)
  27. (pathin-aux filename-tail pathin*))
  28. (de pathin-aux (filename-tail search-path-list)
  29. (if (null search-path-list)
  30. (conterror 99 "File not found in path" (pathin filename-tail))
  31. (let ((test-file (concat (first search-path-list) filename-tail)))
  32. (if (filep test-file)
  33. (evin (list test-file))
  34. (pathin-aux filename-tail (rest search-path-list))))))