From 782c9aee2cfef74b10e56ccdab61c1765c2aaf4b Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 24 Oct 2022 00:19:25 +0100 Subject: [PATCH] implement raw-directory-exists? function in storage package. This differs from the other file/directory checks because it doesn't create a directory when it can't find one (usual Common Lisp predicate behaviour with files/directories). --- src/storage.lisp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/storage.lisp b/src/storage.lisp index 4bb3c1a..58f0370 100644 --- a/src/storage.lisp +++ b/src/storage.lisp @@ -29,7 +29,8 @@ #:copy-storage-directory #:copy-raw-directory #:get-files-in-raw-directory - #:get-raw-subdirectories)) + #:get-raw-subdirectories + #:raw-directory-exists?)) (in-package #:storage) (defun init-storage () @@ -116,13 +117,15 @@ calling this function." "Returns a list of paths for the files in `DIRECTORY-PATH' outside /storage directory." (cl-fad:list-directory (make-raw-path directory-path))) +(defun raw-directory-exists? (directory-path) + "Checks to see if directory at `DIRECTORY-PATH' (no directory make if none found)." + (cl-fad:directory-exists-p (make-raw-path directory-path))) + (defun get-directory-names (directory-names) "Returns the final part of a directories absolute path in `DIRECTORY-NAMES'. Make sure you use `GET-RAW-DIRECTORIES' to build the `DIRECTORY-NAMES' list." (mapcar #'(lambda (x) (first (last (pathname-directory x)))) directory-names)) -;; (first (last (pathname-directory (cl-fad:pathname-directory-pathname (first (cl-fad:list-directory (storage:make-raw-path "snapshots/"))))))) - (defun make-path (username subdirectory slug) "Forms the path used to save a file. Storage path: