On Sat, Nov 29, 2003 at 11:45:28AM +0100, Paolo Amoroso wrote:
> I am looking for a way of recognizing file system
> directories.
A semi-portable way:
(defun dir-p (filedes)
;; signal an error if the file doesn't exist
(let ((path (truename filedes)))
(if (or (pathname-name path) (pathname-type path))
nil
path)))
(remove-if-not #'dir-p (directory "/usr/lib/*"))
;; the DIRECTORY call is non-protable
Or, with Osicat (http://common-lisp.net/project/osicat/):
(require :osicat)
(defun subdirectories (dir)
(osicat:with-directory-iterator (next dir)
(loop for entry = (next)
while entry
when (eq :directory (osicat:file-kind entry))
collect it)))
(subdirectories "/usr/lib/")
Cheers,
-- Nikodemus
-- Attached file included as plaintext by Listar --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQE/yKb7bSpkIAKPfsURAmxzAKCdRW2mqFrSsAu6UCTwv+3egDP20wCePjMr
pJ+Lh/9Q0R/thZp2QaJwGSc=
=l9nS
-----END PGP SIGNATURE-----