utils.scm 511 B

12345678910111213141516171819
  1. (define-module (utils utils)
  2. #:use-module (ice-9 match)
  3. #:use-module (ice-9 ftw)
  4. #:export (files-in-dir))
  5. (define remove-stat
  6. ;; Remove the `stat' object the `file-system-tree' provides
  7. ;; for each file in the tree.
  8. (match-lambda
  9. ((name stat) ; flat file
  10. name)
  11. ((name stat children ...) ; directory
  12. (list name (map remove-stat children)))))
  13. (define (files-in-dir base-dir)
  14. (car (cdr
  15. (let ([dir base-dir])
  16. (remove-stat (file-system-tree dir))))))