mirror of
https://codeberg.org/guix/guix.git
synced 2026-01-25 03:55:08 -06:00
guix: build: utils: Add delete-all-but.
* guix/build/utils.scm (delete-all-but): New variable. Change-Id: I15e1d632a97236b8d18cec3be993c81e138dff04
This commit is contained in:
parent
56598668a7
commit
ad81c9a668
1 changed files with 9 additions and 0 deletions
|
|
@ -77,6 +77,7 @@
|
|||
make-file-writable
|
||||
copy-recursively
|
||||
delete-file-recursively
|
||||
delete-all-but
|
||||
file-name-predicate
|
||||
find-files
|
||||
false-if-file-not-found
|
||||
|
|
@ -522,6 +523,14 @@ errors."
|
|||
;; Don't follow symlinks.
|
||||
lstat)))
|
||||
|
||||
(define (delete-all-but directory . preserve)
|
||||
"Delete DIRECTORY recursively except for the files in PRESERVE immediately
|
||||
found under it."
|
||||
(with-directory-excursion directory
|
||||
(let* ((pred (negate (cut member <> (cons* "." ".." preserve))))
|
||||
(items (scandir "." pred)))
|
||||
(for-each (cut delete-file-recursively <>) items))))
|
||||
|
||||
(define (file-name-predicate regexp)
|
||||
"Return a predicate that returns true when passed a file name whose base
|
||||
name matches REGEXP."
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue