-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.lisp
31 lines (26 loc) · 936 Bytes
/
utils.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
(defpackage utils
(:use cl)
(:export ls path-/ run-repl))
(in-package utils)
(defun path-/ (directory &rest names)
(declare (inline path-/)
(type (or (cons string) (cons pathname)) names)
(type (or string pathname) directory))
(loop for name in names
for acc = (cl-fad:pathname-as-directory directory) then (cl-fad:pathname-as-directory acc)
do (setf acc (merge-pathnames acc name))
finally (return acc)))
(defun ls (path)
(declare (inline ls))
(let ((dir (sb-posix:opendir path)))
(unwind-protect
(loop
:for entry = (sb-posix:readdir dir)
:until (sb-alien:null-alien entry)
:for name = (sb-posix:dirent-name entry)
:unless (or (string= name ".") (string= name ".."))
:collect name)
(sb-posix:closedir dir))))
(defun run-repl (argv)
(declare (ignore argv))
(sb-impl::toplevel-init))