常见的Lisp-获取文件的路径 [英] common lisp - get path to file
问题描述
在Common Lisp中,是否有办法获取已编译文件的路径(类似于当前目录)?
In Common Lisp, is there a way to get the path to a compiled file (something like current-directory)?
该文件不在当前目录文件夹中.
The file is not inside the current-directory folder.
推荐答案
这应该是一个注释,但是我将给出一些代码示例,这些示例可能会有助于原始海报.
This ought to be a comment but I'm going to give some code examples that might help the original poster along.
首先,您需要更加清楚自己想做什么.您要解决的问题是什么?
First of all, you need to be a little more clear about what you want to do. What is the problem you're trying to solve?
第二,下面是一些有用的示例:
Secondly, here are a couple of examples which could be useful:
-
*default-pathname-defaults*
通常设置为启动CL映像的目录在:
*default-pathname-defaults*
usually set to the directory the CL image was started up in:
* *default-pathname-defaults*
#P"/Users/aerique/"
merge-pathnames
允许您构造新的路径名:
merge-pathnames
allows you to construct new pathnames:
* (merge-pathnames "lib/misc" *default-pathname-defaults*)
#P"/Users/aerique/lib/misc"
* (merge-pathnames "lib/misc/" *default-pathname-defaults*)
#P"/Users/aerique/lib/misc/"
asdf:system-source-directory
返回加载了 ASDF 的系统的路径:
asdf:system-source-directory
returns the path to a system loaded with ASDF:
* (asdf:system-source-directory :linedit)
#P"/Users/aerique/quicklisp/dists/quicklisp/software/linedit-20111203-git/"
有关更多有用的文件和系统功能,另请参见链接的ASDF手册.
Also see the linked ASDF manual for more useful file and system functions.
这篇关于常见的Lisp-获取文件的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!