diff --git a/.local/share/common-lisp/source/ambrevar/storage.lisp b/.local/share/common-lisp/source/ambrevar/storage.lisp index c594ff47..e89ae235 100644 --- a/.local/share/common-lisp/source/ambrevar/storage.lisp +++ b/.local/share/common-lisp/source/ambrevar/storage.lisp @@ -10,9 +10,8 @@ (in-package ambrevar/storage) (eval-when (:compile-toplevel :load-toplevel :execute) (trivial-package-local-nicknames:add-package-local-nickname :alex :alexandria) - (trivial-package-local-nicknames:add-package-local-nickname :sera :serapeum)) - -;; TODO: Use pathname-utils to simplify code. + (trivial-package-local-nicknames:add-package-local-nickname :sera :serapeum) + (trivial-package-local-nicknames:add-package-local-nickname :path :pathname-utils)) (defun roots (&optional (prefix "/media/")) (sera:filter (sera:op (str:starts-with? prefix _)) @@ -144,19 +143,13 @@ If DESTINATION ends with '.gpg', it gets GPG-encrypted." :test #'string= :key #'basename)) -(defun parent (path) - "Return the parent directory of PATH." - (if (uiop:directory-pathname-p path) - (uiop:pathname-parent-directory-pathname path) - (uiop:pathname-directory-pathname path))) - (defun depth (file parent) (if (uiop:pathname-equal file parent) 0 - (unless (uiop:pathname-equal (parent file) file) - (or (when (uiop:pathname-equal (parent file) parent) + (unless (uiop:pathname-equal (path:parent file) file) + (or (when (uiop:pathname-equal (path:parent file) parent) 1) - (alex:when-let ((level (depth (parent file) parent))) + (alex:when-let ((level (depth (path:parent file) parent))) (1+ level)))))) (export-always 'list-projects)