问题描述
我在达尔文(Darwin)上使用OpenMCL,我想这样做:
I'm using OpenMCL on Darwin, and I'd like to do something like:
(loop for f in (directory "somedir")
collect (some-per-file-processing f))
但是我无法获得目录
返回除 NIL
以外的任何内容,而且我似乎找不到任何内容很好的在线说明(每个系统不同)。
But I can't get directory
to return anything other than NIL
, and I can't seem to find any good explanation online (other than "its different for each system").
任何指针吗?
推荐答案
您的路径名规范是否包含通配符?起初,Common Lisp的路径名东西有些难以理解-至少对我来说是...... 在目录
函数上的状态:
Does your pathname specification contain a wildcard? Common Lisp's pathname stuff is somewhat hard to grasp at first - at least for me it was... As the CLHS states on the directory
function:
要让您的路径名包含通配符,您可以尝试使用make-pathname函数,例如
In order to have your pathname include a wildcard, you might try the make-pathname function, like
(directory (make-pathname :directory '(:absolute "srv" "hunchentoot") :name :wild :type "lisp"))
甚至
(directory (make-pathname :directory '(:absolute "srv" "hunchentoot") :name :wild :type :wild))
我发现库对于处理路径名和文件系统有很大的帮助米特别是其函数可能比普通的标准目录
函数更易于使用。
I found the CL-FAD library a great help for dealing with pathnames and the file system. In particular, its list-directory
function might be easier to use than the plain standard directory
function.
这篇关于如何遍历Common Lisp中的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!