Listing directories in CLISP

馋奶兔 提交于 2019-12-11 05:08:02

问题


I've been trying to see get a list of all files within a directory in CLISP, but I've only been able to get all non-directory files within a directory.

I'm currently trying this in Windows 7 with cygwin, so that may influence my results. I'm pretty new to CLISP (and LISP over all), and what I'm currently trying to do is as follows:

(directory (make-pathname :directory
'(:absolute "cygdrive" "c" "Download")
:name :wild))

This successfully returns all non-directory files within "C:\Download. However, it doesn't return directories. I've searched all over, and all Common Lisp references point to using "directory", but it seems impossible to me that there is no Common Lisp (or CLISP only perhaps?) way to address all files within a directory.

Any help would be appreciated. Thanks in advance!


回答1:


See the CLISP implementation notes, section 20.3.2:

"If you want all the files and subdirectories in the current directory, you should use (NCONC (DIRECTORY "*/") (DIRECTORY "*"))."




回答2:


In Common Lisp in what turned out to be perhaps an unfortunate decision, directories are not files. Therefore to obtain a list of directories in you example you need a wildcard in the directory fragment:

(directory
 (make-pathname :directory
                '(:absolute "cygdrive" "c" "Download" :wild)))


来源:https://stackoverflow.com/questions/5282089/listing-directories-in-clisp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!