From 413cc50345557e0a516f33b98e8aab19bbc8b4fe Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Mon, 7 Nov 2016 13:12:01 +0100 Subject: [PATCH] gpgscm,w32: Provide schemish file handling for binary files. * tests/gpgscm/lib.scm (call-with-binary-input-file): New function. (call-with-binary-output-file): Likewise. Signed-off-by: Justus Winter --- tests/gpgscm/lib.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/gpgscm/lib.scm b/tests/gpgscm/lib.scm index 270189dcd..a8ae2f805 100644 --- a/tests/gpgscm/lib.scm +++ b/tests/gpgscm/lib.scm @@ -186,6 +186,20 @@ (write-char (apply read-char p) acc) (loop acc)))))) +;; +;; Windows support. +;; + +;; Like call-with-input-file but opens the file in 'binary' mode. +(define (call-with-binary-input-file filename proc) + (letfd ((fd (open filename (logior O_RDONLY O_BINARY)))) + (proc (fdopen fd "rb")))) + +;; Like call-with-output-file but opens the file in 'binary' mode. +(define (call-with-binary-output-file filename proc) + (letfd ((fd (open filename (logior O_WRONLY O_CREAT O_BINARY) #o600))) + (proc (fdopen fd "wb")))) + ;; ;; Libc functions. ;;