~ chicken-core (chicken-5) ba01911d2644dd8ac40eced46a8451033e565d86
commit ba01911d2644dd8ac40eced46a8451033e565d86
Author: Mario Domenech Goulart <mario.goulart@gmail.com>
AuthorDate: Sun Oct 20 22:06:08 2013 -0200
Commit: Christian Kellermann <ckeen@pestilenz.org>
CommitDate: Mon Oct 21 13:25:09 2013 +0200
`##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"
Signed-off-by: Christian Kellermann <ckeen@pestilenz.org>
diff --git a/posix-common.scm b/posix-common.scm
index ca3c355e..3ed0f30d 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 e869f2c1..6ee8993e 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))))
Trap