>From c5de6c69a0f0263ea491879c0c5229f8735cad02 Mon Sep 17 00:00:00 2001 From: Mario Domenech Goulart Date: Sun, 20 Oct 2013 22:06:08 -0200 Subject: [PATCH] `##sys#find-files' bug fix: handle dot files recursively Assuming: $ mkdir -p foo/bar/.baz Old behavior: $ csi -e '(use posix) (print (find-files "foo" dotfiles: #t))' (foo/bar) Behavior with this patch: $ csi -e '(use posix) (print (find-files "foo" dotfiles: #t))' (foo/bar/.baz foo/bar) Without this patch, delete-directory doesn't properly honor the `recursive' optional argument: $ csi -e '(use posix) (delete-directory "foo" #t)' Error: (delete-directory) cannot delete directory - Directory not empty: "foo/bar" --- posix-common.scm | 2 +- tests/posix-tests.scm | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/posix-common.scm b/posix-common.scm index ca3c355..3ed0f30 100644 --- a/posix-common.scm +++ b/posix-common.scm @@ -447,7 +447,7 @@ EOF ((lproc f) (loop rest (fluid-let ((depth (fx+ depth 1))) - (loop (glob (make-pathname f "*")) + (loop (glob (make-pathname f (if dot "?*" "*"))) (if (pproc f) (action f r) r)) ) ) ) (else (loop rest (if (pproc f) (action f r) r))) ) ) ((pproc f) (loop rest (action f r))) diff --git a/tests/posix-tests.scm b/tests/posix-tests.scm index e869f2c..6ee8993 100644 --- a/tests/posix-tests.scm +++ b/tests/posix-tests.scm @@ -42,3 +42,11 @@ (move-memory! (memory-mapped-file-pointer mmap) str size) (assert (blob=? (string->blob data) (string->blob str))) (unmap-file-from-memory mmap)))) + +(let* ((tmp-dir (create-temporary-directory)) + (tmp-dot (make-pathname (list tmp-dir "foo" "bar") ".baz"))) + (create-directory tmp-dot 'recursively) + (assert (directory-exists? tmp-dot)) + (delete-directory tmp-dir 'recursively) + (assert (not (directory-exists? tmp-dot))) + (assert (not (directory-exists? tmp-dir)))) -- 1.7.10.4