with-input-output-from-to-files   scheme


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/runtime/init.xtm

Implementation

(define (with-input-output-from-to-files si so p)
  (let ((inport (open-input-file si))
        (outport (open-input-file so)))
    (if (not (and inport outport))
        (begin
          (close-input-port inport)
          (close-output-port outport)
          #f)
        (let ((prev-inport (current-input-port))
              (prev-outport (current-output-port)))
          (set-input-port inport)
          (set-output-port outport)
          (let ((res (p)))
            (close-input-port inport)
            (close-output-port outport)
            (set-input-port prev-inport)
            (set-output-port prev-outport)
            res)))))


Back to Index