如何将(make-pathname:directory'(:absolute:home"directoryiwant")转换为绝对路径

Sim*_*Sim 4 directory common-lisp

我希望能够将任何操作系统上我的homedirectory中的某个目录转换为该操作系统上的实际绝对路径,例如(make-pathname :directory '(:absolute :home "directoryiwant")应该在unixlike系统上转换为"/ home/weirdusername/directoryiwant".

这样做的选择功能是什么?如

(directory-namestring 
      (make-pathname :directory '(:absolute :home "directoryiwant"))
> "~/"
Run Code Online (Sandbox Code Playgroud)

实际上没有做这笔交易.

Jos*_*lor 8

如果你需要相对于你的主目录的东西,Common Lisp函数user-homedir-pathnamemerge-pathnames可以帮助你:

CL-USER> (merge-pathnames 
          (make-pathname
           :directory '(:relative "directoryyouwant"))
          (user-homedir-pathname))
#P"/home/username/directoryyouwant/"
Run Code Online (Sandbox Code Playgroud)

namestring功能(例如,namestring,目录namestring)这个路径按预期工作:

CL-USER> (directory-namestring
          (merge-pathnames 
           (make-pathname
            :directory '(:relative "directoryyouwant"))
           (user-homedir-pathname)))
"/home/username/directoryyouwant/"
Run Code Online (Sandbox Code Playgroud)