about summary refs log tree commit diff
path: root/users/sterni/mblog/maildir.lisp
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-11-30T16·42+0100
committersterni <sternenseemann@systemli.org>2022-01-30T09·38+0000
commit7577a89284cf3c187af66157796c8a24174b594f (patch)
tree0d50fa4a5581053c2e9e7d8f1577d1119836a422 /users/sterni/mblog/maildir.lisp
parent4803776491f093767131d8849a86ab771afb839e (diff)
feat(sterni/mblog): add package to read maildirs r/3719
Change-Id: I7be8d8b7d12bb194712aa26f3ddad74340357779
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5070
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'users/sterni/mblog/maildir.lisp')
-rw-r--r--users/sterni/mblog/maildir.lisp17
1 files changed, 17 insertions, 0 deletions
diff --git a/users/sterni/mblog/maildir.lisp b/users/sterni/mblog/maildir.lisp
new file mode 100644
index 000000000000..aca014203e29
--- /dev/null
+++ b/users/sterni/mblog/maildir.lisp
@@ -0,0 +1,17 @@
+(in-package :maildir)
+(declaim (optimize (safety 3)))
+
+(defun list (dir)
+  "Returns a list of pathnames to messages in a maildir. The messages are
+  returned in no guaranteed order. Note that this function doesn't fully
+  implement the behavior prescribed by maildir(5): It only looks at `cur`
+  and `new` and won't clean up `tmp` nor move files from `new` to `cur`,
+  since it is strictly read-only."
+  (flet ((subdir-contents (subdir)
+           (directory
+            (merge-pathnames
+             (make-pathname :directory `(:relative ,subdir)
+                            :name :wild :type :wild)
+             dir))))
+    (mapcan #'subdir-contents '("cur" "new"))))
+