-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.lisp
49 lines (40 loc) · 1.49 KB
/
util.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
;;;; Copyright 2018-Present Modern Interpreters Inc.
;;;;
;;;; This Source Code Form is subject to the terms of the Mozilla Public
;;;; License, v. 2.0. If a copy of the MPL was not distributed with this
;;;; file, You can obtain one at https://mozilla.org/MPL/2.0/.
(uiop:define-package :quick-patch/util
(:use #:cl))
(in-package :quick-patch/util)
;;;; from cl-str
(defvar *whitespaces* '(#\Space #\Newline #\Backspace #\Tab
#\Linefeed #\Page #\Return #\Rubout))
(defun trim (value)
(string-trim *whitespaces* value))
;;;; end: from cl-str
;;;; from cl-fad (with slight modifications)
(defun catdir (x y)
(let ((x (pathname x))
(y (pathname y)))
(assert (eql :relative (car (pathname-directory y))))
(make-pathname
:directory (cons
(car (pathname-directory x))
(append (cdr (pathname-directory x)) (cdr (pathname-directory y))))
:defaults x)))
(defun directory-exists-p (pathspec)
"Checks whether the file named by the pathname designator PATHSPEC
exists and if it is a directory. Returns its truename if this is the
case, NIL otherwise. The truename is returned in directory form as if
by PATHNAME-AS-DIRECTORY."
#+:allegro
(and (excl:probe-directory pathspec)
(truename pathspec))
#+:lispworks
(and (lw:file-directory-p pathspec)
(truename pathspec))
#-(or :allegro :lispworks)
(let ((result (probe-file pathspec)))
(and result
(not (pathname-name result)))))
;;;; end: from cl-fad