[standard-reports] compact (directory-files) and remove regex

use string-suffix? instead.
This commit is contained in:
Christopher Lam 2019-03-02 15:01:44 +08:00
parent a6296314a0
commit 117425305b

View File

@ -87,23 +87,23 @@
;; list of files in the directory ;; list of files in the directory
(define (directory-files dir) (define (directory-files dir)
(if (file-exists? dir) (cond
(let ((fname-regexp (make-regexp "\\.scm$")) ((file-exists? dir)
;; Regexp that matches the desired filenames (let ((dir-stream (opendir dir)))
(dir-stream (opendir dir))) (let loop ((fname (readdir dir-stream))
(let loop ((fname (readdir dir-stream)) (acc '()))
(acc '())) (cond
(if (eof-object? fname) ((eof-object? fname)
(begin (closedir dir-stream)
(closedir dir-stream) acc)
acc) (else
(loop (readdir dir-stream) (loop (readdir dir-stream)
(if (regexp-exec fname-regexp fname) (if (string-suffix? ".scm" fname)
(cons fname acc) (cons fname acc)
acc))))) acc)))))))
(begin (else
(gnc:warn "Can't access " dir ".\nEmpty list will be returned.") (gnc:warn "Can't access " dir ".\nEmpty list will be returned.")
'()))) '())))
;; Process a list of files by removing the ".scm" suffix if it exists ;; Process a list of files by removing the ".scm" suffix if it exists
;; ;;