;;; Lisplab, extra.lisp ;;; Some string and file utilities ;;; Copyright (C) 2009 Joern Inge Vestgaarden ;;; ;;; This program is free software; you can redistribute it and/or modify ;;; it under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 2 of the License, or ;;; (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License along ;;; with this program; if not, write to the Free Software Foundation, Inc., ;;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. (in-package :lisplab) (defun strcat (&rest args) "Concatenates the strings." (apply #'concatenate (append (list 'string) args))) (defmacro in-dir (dir &body body) "Temperarily binds *default-pathname-defaults* to dir. When directory does not exists, it is created." (let ((path (gensym)) (dir2 (gensym))) `(let* ((,dir2 ,dir) (,path (merge-pathnames (if (pathnamep ,dir2) ,dir2 (pathname (strcat ,dir2 "/"))) *default-pathname-defaults*))) (ensure-directories-exist ,path) (unless (probe-file ,path) (error "<~S> is no directory" ,path )) (let ((*default-pathname-defaults* ,path)) ,@body))))