Add mkdir-p.
* gash/guix-build-utils.scm (mkdir-p): New function, import from Guix.
This commit is contained in:
parent
3c57272971
commit
03fc5c928a
|
@ -44,6 +44,7 @@
|
||||||
grep-match-line
|
grep-match-line
|
||||||
grep-match-column
|
grep-match-column
|
||||||
grep-match-end-column
|
grep-match-end-column
|
||||||
|
mkdir-p
|
||||||
|
|
||||||
directory-exists?
|
directory-exists?
|
||||||
executable-file?
|
executable-file?
|
||||||
|
@ -212,3 +213,28 @@ transferred and the continuation of the transfer as a thunk."
|
||||||
(lambda (in)
|
(lambda (in)
|
||||||
(grep* pattern #:port in #:file-name file))))
|
(grep* pattern #:port in #:file-name file))))
|
||||||
(else (grep* pattern))))
|
(else (grep* pattern))))
|
||||||
|
|
||||||
|
(define (mkdir-p dir)
|
||||||
|
"Create directory DIR and all its ancestors."
|
||||||
|
(define absolute?
|
||||||
|
(string-prefix? "/" dir))
|
||||||
|
|
||||||
|
(define not-slash
|
||||||
|
(char-set-complement (char-set #\/)))
|
||||||
|
|
||||||
|
(let loop ((components (string-tokenize dir not-slash))
|
||||||
|
(root (if absolute?
|
||||||
|
""
|
||||||
|
".")))
|
||||||
|
(match components
|
||||||
|
((head tail ...)
|
||||||
|
(let ((path (string-append root "/" head)))
|
||||||
|
(catch 'system-error
|
||||||
|
(lambda ()
|
||||||
|
(mkdir path)
|
||||||
|
(loop tail path))
|
||||||
|
(lambda args
|
||||||
|
(if (= EEXIST (system-error-errno args))
|
||||||
|
(loop tail path)
|
||||||
|
(apply throw args))))))
|
||||||
|
(() #t))))
|
||||||
|
|
Loading…
Reference in New Issue