mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-07 15:36:20 -05:00
utils: Add `delete-file-recursively'.
* guix/build/utils.scm (delete-file-recursively): New procedure.
This commit is contained in:
parent
7f614e49e8
commit
e65df6a63a
1 changed files with 21 additions and 0 deletions
|
@ -32,6 +32,7 @@ (define-module (guix build utils)
|
|||
with-directory-excursion
|
||||
mkdir-p
|
||||
copy-recursively
|
||||
delete-file-recursively
|
||||
find-files
|
||||
|
||||
set-path-environment-variable
|
||||
|
@ -147,6 +148,26 @@ (define strip-source
|
|||
#t
|
||||
source))
|
||||
|
||||
(define (delete-file-recursively dir)
|
||||
"Delete DIR recursively, like `rm -rf', without following symlinks. Report
|
||||
but ignore errors."
|
||||
(file-system-fold (const #t) ; enter?
|
||||
(lambda (file stat result) ; leaf
|
||||
(delete-file file))
|
||||
(const #t) ; down
|
||||
(lambda (dir stat result) ; up
|
||||
(rmdir dir))
|
||||
(const #t) ; skip
|
||||
(lambda (file stat errno result)
|
||||
(format (current-error-port)
|
||||
"warning: failed to delete ~a: ~a~%"
|
||||
file (strerror errno)))
|
||||
#t
|
||||
dir
|
||||
|
||||
;; Don't follow symlinks.
|
||||
lstat))
|
||||
|
||||
(define (find-files dir regexp)
|
||||
"Return the list of files under DIR whose basename matches REGEXP."
|
||||
(define file-rx
|
||||
|
|
Loading…
Reference in a new issue