From fba4b359fa879dc4d216d1ffc3ff5dc8a0500db3 Mon Sep 17 00:00:00 2001 From: Leo Butler Date: Tue, 8 Dec 2020 12:46:16 -0600 Subject: [PATCH] add a write-to-file function for exporting stuff --- ffmpeg-myth.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ffmpeg-myth.scm b/ffmpeg-myth.scm index c8bbd9d..d76af0f 100755 --- a/ffmpeg-myth.scm +++ b/ffmpeg-myth.scm @@ -27,6 +27,14 @@ (define (roundx x) (inexact->exact (round x))) +(define (write-to-file obj filename) + (let ((port (open-file filename "w"))) + (catch 'write-error + ;; thunk + (lambda () (simple-format port "~a" obj) (force-output) (close port)) + ;; handler + (lambda () (close port) 'write-error)))) + (define* (shell-command-to-string* cmd args) (let* ((port (apply open-pipe* (append (list OPEN_READ cmd) args))) (str (read-string port)))