Browse Source

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).
stable
Craig Oates 2 years ago
parent
commit
782c9aee2c
  1. 9
      src/storage.lisp

9
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:

Loading…
Cancel
Save