ClozureCLのdirectory関数でディレクトリ一覧を取得する方法
CCLのdirectory関数を使ってディレクトリ一覧を取得する方法。
普通に(?)ワイルドカードでマッチさせようとしてもnilが返ってくる。
;;;; ccl-1.5 ;; Ubuntuのルートディレクトリをリストしたい (directory "/*/") --> NIL
マニュアルを見ると、CCLのdirectory関数には独自拡張のキーワード引数がいくつかあって、その内のdirectories引数にtを与えないと、ディレクトリは除外されるらしい(デフォルトはnil)。
;; Ubuntuのルートディレクトリをリストしたい (directory "/*/" :directories t) --> (#P"/bin/" #P"/boot/" #P"/cdrom/" #P"/dev/" #P"/etc/" #P"/home/" #P"/lib/" #P"/lost+found/" #P"/media/" #P"/mnt/" #P"/proc/" #P"/root/" #P"/sbin/" #P"/selinux/" #P"/srv/" #P"/sys/" #P"/tmp/" #P"/usr/" #P"/var/")
以下はdirectory関数のdescribe結果。
(describe #'directory) #<Compiled-function DIRECTORY #x101243AE> Name: DIRECTORY Arglist (analysis): (CCL::PATH &KEY :DIRECTORIES :FILES :ALL :DIRECTORY-PATHNAMES :INCLUDE-EMACS-LOCKFILES :TEST :FOLLOW-LINKS) Documentation: "Return a list of PATHNAMEs, each the TRUENAME of a file that matched the given pathname. Note that the interaction between this ANSI-specified TRUENAMEing and the semantics of the Unix filesystem (symbolic links..) means this function can sometimes return files which don't have the same directory as PATHNAME." Source Location: #<SOURCE-NOTE *"ccl:lib;pathnames.lisp":13056-14679 NIL>