(define-module (utils utils)
  #:use-module (ice-9 match)
  #:use-module (ice-9 ftw)
  #:export (files-in-dir))

(define remove-stat
  ;; Remove the `stat' object the `file-system-tree' provides
  ;; for each file in the tree.
  (match-lambda
    ((name stat)              ; flat file
     name)
    ((name stat children ...) ; directory
     (list name (map remove-stat children)))))

(define (files-in-dir base-dir)
  (car (cdr
        (let ([dir base-dir])
          (remove-stat (file-system-tree dir))))))
