Directory 获取公共Lisp中路径名的最后一个组件

Directory 获取公共Lisp中路径名的最后一个组件,directory,common-lisp,pathname,Directory,Common Lisp,Pathname,而我可以建立一个路径名,例如 (make-pathname :directory '(:RELATIVE "dir" "subdir" "subsubdir")) 如何从这样的路径名(假设它是一个目录)返回subsubdir?我需要从路径名中提取最后一个目录,就像此Unix命令所做的那样: $ basename /usr/local/share/ share 请参见常见的Lisp Hyperspec 这只处理路径以斜线结束的情况。如果您有一个路径a/b/c,上面的代码将返回b,而basena

而我可以建立一个路径名,例如

(make-pathname :directory '(:RELATIVE "dir" "subdir" "subsubdir"))
如何从这样的路径名(假设它是一个目录)返回
subsubdir
?我需要从路径名中提取最后一个目录,就像此Unix命令所做的那样:

$ basename /usr/local/share/
share

请参见常见的Lisp Hyperspec


这只处理路径以斜线结束的情况。如果您有一个路径
a/b/c
,上面的代码将返回
b
,而basename返回
c
@KevinChen:他是在用Lisp路径名提问。Unix basename命令只是一个例子。
(first (last (pathname-directory some-pathname)))