utils: 'current-source-directory' returns the absolute directory name.
* guix/utils.scm (current-source-directory): When FILE-NAME is relative, use 'search-path' to determine the absolute file name.master
parent
5dbae738f0
commit
d4dd37fc46
|
@ -704,12 +704,18 @@ output port, and PROC's result is returned."
|
||||||
|
|
||||||
(define-syntax current-source-directory
|
(define-syntax current-source-directory
|
||||||
(lambda (s)
|
(lambda (s)
|
||||||
"Return the current directory name or #f if it could not be determined."
|
"Return the absolute name of the current directory, or #f if it could not
|
||||||
|
be determined."
|
||||||
(syntax-case s ()
|
(syntax-case s ()
|
||||||
((_)
|
((_)
|
||||||
(match (assq 'filename (syntax-source s))
|
(match (assq 'filename (syntax-source s))
|
||||||
(('filename . (? string? file-name))
|
(('filename . (? string? file-name))
|
||||||
(dirname file-name))
|
;; If %FILE-PORT-NAME-CANONICALIZATION is 'relative, then FILE-NAME
|
||||||
|
;; can be relative. In that case, we try to find out the absolute
|
||||||
|
;; file name by looking at %LOAD-PATH.
|
||||||
|
(if (string-prefix? "/" file-name)
|
||||||
|
(dirname file-name)
|
||||||
|
(and=> (search-path %load-path file-name) dirname)))
|
||||||
(_
|
(_
|
||||||
#f))))))
|
#f))))))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue