filesys.scm 849 B

123456789101112131415161718192021222324252627282930313233
  1. #!r6rs
  2. ;;; filesys.sls --- Filsystem utilities for `include'
  3. ;; Copyright (C) 2010 Andreas Rottmann <a.rottmann@gmx.at>
  4. ;; This program is free software, you can redistribute it and/or
  5. ;; modify it under the terms of the MIT/X11 license.
  6. ;; You should have received a copy of the MIT/X11 license along with
  7. ;; this program. If not, see
  8. ;; <http://www.opensource.org/licenses/mit-license.php>.
  9. ;;; Commentary:
  10. ;;; Code:
  11. (library (arguile lib private include filesys)
  12. (export find-file)
  13. (import (rnrs base)
  14. (rnrs files)
  15. (arguile lib private include compat))
  16. (define (find-file path origins)
  17. (let loop ((origins origins))
  18. (if (null? origins)
  19. #f
  20. (let ((filename (merge-path path (car origins))))
  21. (if (file-exists? filename)
  22. filename
  23. (loop (cdr origins)))))))
  24. )