|
@@ -0,0 +1,26 @@
|
|
1
|
+(in-package :coleslaw)
|
|
2
|
+
|
|
3
|
+(defun app-path (path &rest args)
|
|
4
|
+ "Take a relative PATH and return the corresponding pathname beneath coleslaw.
|
|
5
|
+If ARGS is provided, use (apply 'format nil PATH ARGS) as the value of PATH."
|
|
6
|
+ (merge-pathnames (apply 'format nil path args) coleslaw-conf:*basedir*))
|
|
7
|
+
|
|
8
|
+(defun to-pathname (file &optional (parent coleslaw-conf:*basedir*))
|
|
9
|
+ "Convert an iolib file-path back to a pathname."
|
|
10
|
+ (merge-pathnames (file-path-namestring file) parent))
|
|
11
|
+
|
|
12
|
+(defun read-symlink (path)
|
|
13
|
+ "A trivial wrapper over iolib.os that returns the pathname in the symlink PATH."
|
|
14
|
+ (to-pathname (iolib.os:read-symlink path)))
|
|
15
|
+
|
|
16
|
+(defmacro do-files ((var path &optional extension) &body body)
|
|
17
|
+ "For each file under PATH, run BODY. If EXTENSION is provided, only run BODY
|
|
18
|
+on files that match the given extension."
|
|
19
|
+ (alexandria:with-gensyms (ext)
|
|
20
|
+ `(mapcar (lambda (,var)
|
|
21
|
+ ,@(if extension
|
|
22
|
+ `((let ((,ext (pathname-type ,var)))
|
|
23
|
+ (when (and ,ext (string= ,ext ,extension))
|
|
24
|
+ ,@body)))
|
|
25
|
+ `,body))
|
|
26
|
+ (list-directory ,path))))
|