summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrice Waegeneire <brice@waegenei.re>2025-06-23 21:36:30 +0200
committerNguyễn Gia Phong <cnx@loang.net>2026-08-31 11:00:19 +0900
commit7bb144e6654e258650c942dfddd335840e1c2d1d (patch)
treeea280bf5236ac41682811cbf939deb6c75ef6d83
parentc62ebcd02c2eb190ab5dc157475ef4a93a1c7581 (diff)
build: utils: Add #:enter? parameter to 'find-files'.
* guix/utils.scm (find-files): Add #:enter? parameter. Merges: https://codeberg.org/guix/guix/pulls/785 Reviewed-by: Hilton Chain <hako@ultrarare.space> Reviewed-by: Florian Pelz <pelzflorian@pelzflorian.de> Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
-rw-r--r--guix/build/utils.scm11
1 files changed, 7 insertions, 4 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 94714bf3973..99d4626acf9 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -10,6 +10,7 @@
10;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@telenet.be> 10;;; Copyright © 2021, 2022 Maxime Devos <maximedevos@telenet.be>
11;;; Copyright © 2021 Brendan Tildesley <mail@brendan.scot> 11;;; Copyright © 2021 Brendan Tildesley <mail@brendan.scot>
12;;; Copyright © 2023 Carlo Zancanaro <carlo@zancanaro.id.au> 12;;; Copyright © 2023 Carlo Zancanaro <carlo@zancanaro.id.au>
13;;; Copyright © 2025 Brice Waegeneire <brice@waegenei.re>
13;;; 14;;;
14;;; This file is part of GNU Guix. 15;;; This file is part of GNU Guix.
15;;; 16;;;
@@ -534,19 +535,21 @@ name matches REGEXP."
534(define* (find-files dir #:optional (pred (const #t)) 535(define* (find-files dir #:optional (pred (const #t))
535 #:key (stat lstat) 536 #:key (stat lstat)
536 directories? 537 directories?
537 fail-on-error?) 538 fail-on-error?
539 (enter? (const #t)))
538 "Return the lexicographically sorted list of files under DIR for which PRED 540 "Return the lexicographically sorted list of files under DIR for which PRED
539returns true. PRED is passed two arguments: the absolute file name, and its 541returns true. PRED is passed two arguments: the absolute file name, and its
540stat buffer; the default predicate always returns true. PRED can also be a 542stat buffer; the default predicate always returns true. PRED can also be a
541regular expression, in which case it is equivalent to (file-name-predicate 543regular expression, in which case it is equivalent to (file-name-predicate
542PRED). STAT is used to obtain file information; using 'lstat' means that 544PRED). STAT is used to obtain file information; using 'lstat' means that
543symlinks are not followed. If DIRECTORIES? is true, then directories will 545symlinks are not followed. If DIRECTORIES? is true, then directories will also
544also be included. If FAIL-ON-ERROR? is true, raise an exception upon error." 546be included. If FAIL-ON-ERROR? is true, raise an exception upon error. Enter
547sub-directories only when (ENTER? path stat result) returns true."
545 (let ((pred (if (procedure? pred) 548 (let ((pred (if (procedure? pred)
546 pred 549 pred
547 (file-name-predicate pred)))) 550 (file-name-predicate pred))))
548 ;; Sort the result to get deterministic results. 551 ;; Sort the result to get deterministic results.
549 (sort (file-system-fold (const #t) 552 (sort (file-system-fold enter?
550 (lambda (file stat result) ; leaf 553 (lambda (file stat result) ; leaf
551 (if (pred file stat) 554 (if (pred file stat)
552 (cons file result) 555 (cons file result)