common lisp - get path to file

后端 未结 5 2362
南旧
南旧 2021-02-19 19:49

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.

5条回答
  •  一个人的身影
    2021-02-19 20:12

    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* usually set to the directory the CL image was started up in:

      * *default-pathname-defaults*
      #P"/Users/aerique/"
      
    • 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 returns the path to a system loaded with ASDF:

      * (asdf:system-source-directory :linedit)  
      #P"/Users/aerique/quicklisp/dists/quicklisp/software/linedit-20111203-git/"
      

    Also see the linked ASDF manual for more useful file and system functions.

提交回复
热议问题