From 3c8c1fe74bfdbf0f600444c137e0055581b1daa4 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Thu, 3 Oct 2013 09:37:33 +0900 Subject: [PATCH] Handling case where opendir fails in directory-fold-tree. --- lib/chibi/filesystem.scm | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/chibi/filesystem.scm b/lib/chibi/filesystem.scm index e8893d53..d4a23a7a 100644 --- a/lib/chibi/filesystem.scm +++ b/lib/chibi/filesystem.scm @@ -49,17 +49,18 @@ (cond ((file-directory? file) (let ((d (opendir file))) - (let lp ((acc acc)) - (let ((e (readdir d))) - (cond - (e - (let ((f (dirent-name e))) - (if (member f '("." "..")) - (lp acc) - (let ((path (string-append file "/" f))) - (lp (fold path (down path acc))))))) - (else - (up file acc))))))) + (if (not d) + (let lp ((acc acc)) + (let ((e (readdir d))) + (cond + (e + (let ((f (dirent-name e))) + (if (member f '("." "..")) + (lp acc) + (let ((path (string-append file "/" f))) + (lp (fold path (down path acc))))))) + (else + (up file acc)))))))) (else (here file acc))))))