diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-21 16:04:17 +0200 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-07-21 16:04:17 +0200 |
commit | faf9245e35f865c604447e5ff84a1d900ac77fd8 (patch) | |
tree | 7c1ee371a1d8d15022ab429671e6d935daaad2bf /module/hnh/util/io.scm | |
parent | Add read-file. (diff) | |
parent | Add script to generate graphviz output from peg deffinitions. (diff) | |
download | calp-faf9245e35f865c604447e5ff84a1d900ac77fd8.tar.gz calp-faf9245e35f865c604447e5ff84a1d900ac77fd8.tar.xz |
Merge call-with-tmpfile and diffs for testrunner.
Merge branch 'next' into c-parser
Diffstat (limited to 'module/hnh/util/io.scm')
-rw-r--r-- | module/hnh/util/io.scm | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/module/hnh/util/io.scm b/module/hnh/util/io.scm index 6aed85ac..2fbad39f 100644 --- a/module/hnh/util/io.scm +++ b/module/hnh/util/io.scm @@ -5,6 +5,7 @@ open-output-port read-lines with-atomic-output-to-file + call-with-tmpfile read-file)) (define (open-input-port str) @@ -64,6 +65,14 @@ ;; value might as well return #f) #f)))) +(define* (call-with-tmpfile proc key: (tmpl "/tmp/file-XXXXXXX")) + (let* ((filename (string-copy tmpl)) + (port (mkstemp! filename))) + (with-continuation-barrier + (lambda () + (begin1 + (proc port filename) + (close-port port)))))) (define (read-file path) (call-with-input-file path read-string)) |