Improve the initial report loading code so that it loads only files ending with .scm.

This should avoid accidentally loading .scm~ backup files etc. The code
matches the filenames against the regexp "\.scm$", so the previous hand-
written comparison against "." and ".." is no longer necessary as those don't
match that regexp anyway.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19309 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2010-06-27 18:56:56 +00:00
parent 8c8fcd39af
commit f4a684f0fd

View File

@ -76,25 +76,25 @@
;; list of files in the directory ;; list of files in the directory
(define (directory-files dir) (define (directory-files dir)
(let ((dir-stream (opendir dir))) (let ((fname-regexp (make-regexp "\.scm$")) ;; Regexp that matches the desired filenames
(let loop ((new (readdir dir-stream)) (dir-stream (opendir dir)))
(let loop ((fname (readdir dir-stream))
(acc '()) (acc '())
) )
(if (eof-object? new) (if (eof-object? fname)
(begin (begin
(closedir dir-stream) (closedir dir-stream)
acc acc
) )
(loop (readdir dir-stream) (loop (readdir dir-stream)
(if (or (string=? "." new) ;;; ignore (if (regexp-exec fname-regexp fname)
(string=? ".." new)) ;;; ignore (cons fname acc)
acc acc
(cons new acc) )
)
) )
) )
)
) )
)
) )
;; 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