(defun find-path-from-top-directory (name dirs) "name というファイル名をディレクトリ配下で検索して、フルパスを返す。存在しなければ nil を返す。 同名ファイルが複数個存在したとしても、最初に見つけた1つしか返さない。 検索対象のディレクトリはリストで与えてもよい。ディレクトリ名の検索には使えない。" (flet ((get-path-list (dir wild) (directory dir :absolute t :recursive t :file-only t :wild wild)) (name-filter (name path) (let ((n (car (last (split-string path #\/))))) (if (string-equal name n) path nil)))) (unless (consp dirs) (setq dirs (cons dirs nil))) (let* ((ext (pathname-type name)) (w (if ext (concat "*." ext) "*")) find) (dolist (d dirs) (when (file-exist-p d) (setq find (find name (get-path-list d w) :test #'name-filter))) (when find (return find))))))