我需要一種方式來獲得運行腳本(包含源文件的目錄)的路徑,但球拍:如何檢索正在運行的文件的路徑?
(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。 –