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 <justus@g10code.com>
This commit is contained in:
Justus Winter 2016-11-07 13:12:01 +01:00
parent 6e677f9b55
commit 413cc50345
1 changed files with 14 additions and 0 deletions

View File

@ -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.
;;