Is it possible to 'stat' a file and find its file type - regular or directory?
views:
51answers:
4CLISP has a function EXT:PROBE-DIRECTORY
, which tells you whether a file exists and is a directory.
Note that this function is specific to CLISP and not standard common list.
I don't know if there's a portable built-in way to do it, but CL-FAD has a function DIRECTORY-EXISTS-P which might help.
Read the chapter about a portable pathname library from Peter Seibel's Practical Common Lisp book. It's available for free. It has a function file-exists-p that will return a pathname when the file exists or nil if it doesn't. The returned pathname will be in directory form if it's a directory. He also gives another function for checking if the pathname is indeed in directory form.
BTW the whole book is really worth reading so check it out if you haven't already.
There are I think several ways. probe-file followed by checking the returned true name to determine that it has a directory name but not a filename and type should do it. e.g. for a directory
(pathname-name (probe-file filespec)) -> NIL