utils: Add 'false-if-file-not-found'.
* guix/build/utils.scm (false-if-file-not-found): New macro.
This commit is contained in:
parent
5e268faf85
commit
5c6391b33a
|
@ -1,5 +1,5 @@
|
|||
;;; GNU Guix --- Functional package management for GNU
|
||||
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
|
||||
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
|
||||
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
|
||||
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
|
||||
|
@ -61,6 +61,7 @@ (define-module (guix build utils)
|
|||
delete-file-recursively
|
||||
file-name-predicate
|
||||
find-files
|
||||
false-if-file-not-found
|
||||
|
||||
search-path-as-list
|
||||
set-path-environment-variable
|
||||
|
@ -396,6 +397,15 @@ (define* (find-files dir #:optional (pred (const #t))
|
|||
stat)
|
||||
string<?)))
|
||||
|
||||
(define-syntax-rule (false-if-file-not-found exp)
|
||||
"Evaluate EXP but return #f if it raises to 'system-error with ENOENT."
|
||||
(catch 'system-error
|
||||
(lambda () exp)
|
||||
(lambda args
|
||||
(if (= ENOENT (system-error-errno args))
|
||||
#f
|
||||
(apply throw args)))))
|
||||
|
||||
|
||||
;;;
|
||||
;;; Search paths.
|
||||
|
|
Loading…
Reference in a new issue