~ruther/ruthless-guix

ref: 1b04ab2be68b55b5215972d1549c4e9bf62da0ae ruthless-guix/modules/ruther/build/utils.scm -rw-r--r-- 391 bytes
1b04ab2b — Rutherther chore: add utils for searching patches. 9 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
(define-module (ruther build utils)
  #:use-module (ice-9 popen)
  #:use-module (ice-9 textual-ports)
  #:export (file-is-text-file?))

(define (file-is-text-file? file)
  (let* ((port
         (open-input-pipe (string-append "file -b0 --mime-encoding " (canonicalize-path file))))
         (output (get-string-all port)))
    (close-pipe port)
    (not (string-contains output "binary"))))