Pergunta

SBCL (directory "*") is filtering out some file names based on extension. How do I get it to return all files, or especially all files matching a pattern (as in bash globing)

(directory "*") ;Lists some files, not all (directory "MyFile") ;Lists some files, but again, filters by extension

Extensions that seem to me ignored... at least *.lisp is not listed.

SBCL 1.1.2-1.fc18 on Fedora18

Foi útil?

Solução 2

The translation from globs to pathnames is implementation and system dependent. Pathnames distinguish the filename and the filetype (extension). When you specify just *, SBCL on Linux interprets this as "any filename, but extension must be empty". You can say *.* to specify all files. The . in *.* is interpreted as the separation between filename and extension, so *.* means not just the filenames containing a literal dot.

Outras dicas

May be you should use native form:

(directory (make-pathname :name :wild :type :wild))

As all this strange signs *?.* don't increase understandability of the code. Lisp is not supposed to be one-liners language. :)

But if you want just list all files in the directory, you may use cl-fad function list-directory.

Lisp uses paths and they call *.XXX the type of the file. (directory "*") is filtering some "types" (I still don't understand it all), but freenode.net IRC user pjb points out

(concatenate 'list (directory "*.*") (directory "*")  (directory "*/"))

and that does better. (Still not perfect, but passable and pointing in the right direction.)

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top