summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-12-09 15:36:28 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-12-09 15:36:28 -0800
commit6cf10451395c20fad177704a3b5032106d083b88 (patch)
treee3eeae3b9fdcffa109f1a96a3215e9feec469746 /share
parent6a88c55cdf0bd3bd6fc33086529bf4e79fd1e03e (diff)
downloadtxr-6cf10451395c20fad177704a3b5032106d083b88.tar.gz
txr-6cf10451395c20fad177704a3b5032106d083b88.tar.bz2
txr-6cf10451395c20fad177704a3b5032106d083b88.zip
New function: path-dir-empty.
* lisplib.c (path_test_set_entries): Autoload entry for path-dir-empty. * share/txr/stdlib/path-test.tl (path-dir-empty): New function. * txr.1: Documented.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/path-test.tl9
1 files changed, 9 insertions, 0 deletions
diff --git a/share/txr/stdlib/path-test.tl b/share/txr/stdlib/path-test.tl
index ee211ff2..4ebb1e3e 100644
--- a/share/txr/stdlib/path-test.tl
+++ b/share/txr/stdlib/path-test.tl
@@ -174,3 +174,12 @@
(and s0 s1
(eql s0.dev s1.dev)
(eql s0.ino s1.ino)))))
+
+(defun path-dir-empty (path)
+ (when (path-dir-p path)
+ (let ((name (if (stringp path) path path.path)))
+ (with-stream (ds (open-directory name))
+ (for (ent) ((set ent (get-line ds)) t) ()
+ (casequal ent
+ (("." ".."))
+ (t (return nil))))))))