From b225bb05e8c2cd08ec1fe8b9cbbb0ed912c4f891 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Sat, 5 Jun 2021 13:22:39 +0200 Subject: [PATCH] ambrevar/storage: have subpath accept lists as well. --- .../common-lisp/source/ambrevar/storage.lisp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.local/share/common-lisp/source/ambrevar/storage.lisp b/.local/share/common-lisp/source/ambrevar/storage.lisp index e89ae235..d3f27f87 100644 --- a/.local/share/common-lisp/source/ambrevar/storage.lisp +++ b/.local/share/common-lisp/source/ambrevar/storage.lisp @@ -21,14 +21,16 @@ (cmd:$cmd "findmnt -n --fstab --output TARGET --json"))))))) (defun subpath (root &rest subdirs) + "Return merged paths as a string. +SUBDIRS can be either a single path or a list of paths." (str:join (fof:separator) - (cons root subdirs))) + (cons root (alex:flatten subdirs)))) (defun personal (&rest subdirs) - (apply #'subpath (uiop:getenv "PERSONAL") subdirs)) + (subpath (uiop:getenv "PERSONAL") subdirs)) (defun home (&rest subdirs) - (apply #'subpath (uiop:getenv "HOME") subdirs)) + (subpath (uiop:getenv "HOME") subdirs)) (defun basename (pathname) (first (last (pathname-directory (uiop:ensure-directory-pathname pathname))))) @@ -80,11 +82,11 @@ If DESTINATION ends with '.gpg', it gets GPG-encrypted." (defun write-roots-index (&optional (destination (personal "index"))) "Write indexes of `roots' sub-directories to DESTINATION." (labels ((write-simple-index (target &rest destination-subdir) - (write-index target (apply #'subpath destination - (append - destination-subdir - (list - (str:concat (fof:basename target) ".index")))))) + (write-index target (subpath destination + (append + destination-subdir + (list + (str:concat (fof:basename target) ".index")))))) (index1 (root) (ambrevar/shell:make-directory destination) (alex:mappend