我需要一种方式来获得运行脚本(包含源文件的目录)的路径,但球拍:如何检索正在运行的文件的路径?
(current-directory)
从来没有指出存在(在这种情况下,外部驱动器),而是一些预定义位置。
我创建了一个文件来尝试所有的'find-system-path',但没有一个是正在运行的文件!球拍文件没有帮助。
#lang web-server/insta
(define (start request)
(local [{define (build-ul items)
`(ul ,@(map itemize items))}
{define (itemize item)
`(li ,(some-system-path->string (find-system-path item)))}]
(response/xexpr
`(html
(head (title "Directories"))
(body (h1 ,"Some Paths")
(p ,(build-ul special-paths)))))))
(define special-paths (list 'home-dir
'pref-dir
'pref-file
'temp-dir
'init-dir
'init-file
;'links-file ; not available for Linux
'addon-dir
'doc-dir
'desk-dir
'sys-dir
'exec-file
'run-file
'collects-dir
'orig-dir))
的目的是为了本地Web服务器应用程序(音乐服务器),将修改包含源文件的目录下的子目录。我将把这个应用程序放在一个USB存储棒上,所以它需要能够找到它自己的目录,因为我在机器和安装有Racket的操作系统之间进行传输。
@SquareCrow:回复你的建议编辑 - 这是不需要的,我最后提到的“HERE”定义完全没有使用“仅路径”。 –
'(在path-only(path-> complete-path(find-system-path'run-file)))'在DrRacket上运行时不起作用。它将路径返回到DrRacket。 –