From 8174b1fb2e3c2a39b5df90e5ef162b2032b1f4b4 Mon Sep 17 00:00:00 2001 From: "Henry M. Wu" Date: Tue, 26 May 1992 23:08:56 +0000 Subject: [PATCH] Added binary file support. --- v7/src/runtime/input.scm | 22 +++++++++++++++++----- v7/src/runtime/output.scm | 20 ++++++++++++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/v7/src/runtime/input.scm b/v7/src/runtime/input.scm index c61950ddd..0844b807d 100644 --- a/v7/src/runtime/input.scm +++ b/v7/src/runtime/input.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/input.scm,v 14.14 1991/11/26 07:06:21 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/input.scm,v 14.15 1992/05/26 23:08:41 mhwu Exp $ Copyright (c) 1988-91 Massachusetts Institute of Technology @@ -86,17 +86,29 @@ MIT in each case. |# (guarantee-input-port port) (fluid-let ((*current-input-port* port)) (thunk))) -(define (call-with-input-file input-specifier receiver) - (let ((port (open-input-file input-specifier))) +(define ((make-call-with-input-file open) input-specifier receiver) + (let ((port (open input-specifier))) (let ((value (receiver port))) (close-port port) value))) -(define (with-input-from-file input-specifier thunk) - (call-with-input-file input-specifier +(define call-with-input-file + (make-call-with-input-file open-input-file)) + +(define call-with-binary-input-file + (make-call-with-input-file open-binary-input-file)) + +(define ((make-with-input-from-file call) input-specifier thunk) + (call input-specifier (lambda (port) (fluid-let ((*current-input-port* port)) (thunk))))) + +(define with-input-from-file + (make-with-input-from-file call-with-input-file)) + +(define with-input-from-binary-file + (make-with-input-from-file call-with-binary-input-file)) ;;;; Input Procedures diff --git a/v7/src/runtime/output.scm b/v7/src/runtime/output.scm index d07e52e20..8e492d9bd 100644 --- a/v7/src/runtime/output.scm +++ b/v7/src/runtime/output.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/output.scm,v 14.12 1991/11/26 07:06:35 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/output.scm,v 14.13 1992/05/26 23:08:56 mhwu Exp $ Copyright (c) 1988-91 Massachusetts Institute of Technology @@ -87,17 +87,29 @@ MIT in each case. |# (guarantee-output-port port) (fluid-let ((*current-output-port* port)) (thunk))) -(define (call-with-output-file output-specifier receiver) +(define ((make-call-with-output-file open) output-specifier receiver) (let ((port (open-output-file output-specifier))) (let ((value (receiver port))) (close-port port) value))) -(define (with-output-to-file output-specifier thunk) - (call-with-output-file output-specifier +(define call-with-output-file + (make-call-with-output-file open-output-file)) + +(define call-with-binary-output-file + (make-call-with-output-file open-binary-output-file)) + +(define ((make-with-output-to-file call) output-specifier thunk) + (call output-specifier (lambda (port) (fluid-let ((*current-output-port* port)) (thunk))))) + +(define with-output-to-file + (make-with-output-to-file call-with-output-file)) + +(define with-output-to-binary-file + (make-with-output-to-file call-with-binary-output-file)) ;;;; Output Procedures -- 2.25.1