【入門】Common Lisp その3【質問よろず】
■ このスレッドは過去ログ倉庫に格納されています
0150デフォルトの名無しさん
2007/07/01(日) 01:38:22ファイルやディレクトリを扱うには Edi Weitz 氏の CL-FAD (File And Directory) が今は標準的。
元は Peter Seibel が Practical Common Lisp 書くときに用意したやつで、Edi 氏がパッケージにして公開してくれる。
で、件の処理はパッケージ内で以下のように定義されてる。pathname-name と pathname-type が無いものがディレクトリであると。
これで不自由はしてないよ。
(defun component-present-p (value)
"Helper function for DIRECTORY-PATHNAME-P which checks whether VALUE
is neither NIL nor the keyword :UNSPECIFIC."
(and value (not (eql value :unspecific))))
(defun directory-pathname-p (pathspec)
"Returns NIL if PATHSPEC \(a pathname designator) does not designate
a directory, PATHSPEC otherwise. It is irrelevant whether file or
directory designated by PATHSPEC does actually exist."
(and
(not (component-present-p (pathname-name pathspec)))
(not (component-present-p (pathname-type pathspec)))
pathspec))
ロード方法: SBCL なら cl-fad.tar.gz をダウンロードして展開後、
CL-USER> (load "cl-fad.asd")
CL-USER> (asdf:oos 'asdf:load-op :cl-fad)
CLISP なら ASDF も別途インストールしてくれ。
■ このスレッドは過去ログ倉庫に格納されています