sbcl stuff
This commit is contained in:
parent
1d1dbc34df
commit
5d91dbb667
335 changed files with 119806 additions and 1 deletions
40
sbcl/.quicklisp/quicklisp/config.lisp
Normal file
40
sbcl/.quicklisp/quicklisp/config.lisp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
;;;; config.lisp
|
||||
|
||||
(in-package #:ql-config)
|
||||
|
||||
(defun config-value-file-pathname (path)
|
||||
(let ((bad-position (position #\Space path)))
|
||||
(when bad-position
|
||||
(error "Space not allowed at position ~D in ~S"
|
||||
bad-position
|
||||
path)))
|
||||
(let* ((space-path (substitute #\Space #\/ path))
|
||||
(split (split-spaces space-path))
|
||||
(directory-parts (butlast split))
|
||||
(name (first (last split)))
|
||||
(base (qmerge "config/")))
|
||||
(merge-pathnames
|
||||
(make-pathname :name name
|
||||
:type "txt"
|
||||
:directory (list* :relative directory-parts))
|
||||
base)))
|
||||
|
||||
(defun config-value (path)
|
||||
(let ((file (config-value-file-pathname path)))
|
||||
(with-open-file (stream file :if-does-not-exist nil)
|
||||
(when stream
|
||||
(values (read-line stream nil))))))
|
||||
|
||||
(defun (setf config-value) (new-value path)
|
||||
(let ((file (config-value-file-pathname path)))
|
||||
(typecase new-value
|
||||
(null
|
||||
(delete-file-if-exists file))
|
||||
(string
|
||||
(ensure-directories-exist file)
|
||||
(with-open-file (stream file :direction :output
|
||||
:if-does-not-exist :create
|
||||
:if-exists :rename-and-delete)
|
||||
(write-line new-value stream)))
|
||||
(t
|
||||
(error "Bad config value ~S; must be a string or NIL" new-value)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue