mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 17:27:33 +02:00
Initial version of with-output-to-file, still needs debugging
This commit is contained in:
parent
ff634d8e18
commit
68fedae3ff
2 changed files with 22 additions and 6 deletions
|
@ -1,9 +1,15 @@
|
||||||
(define-library (scheme file)
|
(define-library (scheme file)
|
||||||
(export
|
(export
|
||||||
call-with-input-file
|
call-with-input-file
|
||||||
call-with-output-file
|
call-with-output-file
|
||||||
with-input-from-file
|
;delete-file
|
||||||
with-output-from-file
|
;file-exists?
|
||||||
|
;open-binary-input-file
|
||||||
|
;open-binary-output-file
|
||||||
|
;open-input-file
|
||||||
|
;open-output-file
|
||||||
|
with-input-from-file
|
||||||
|
with-output-to-file
|
||||||
)
|
)
|
||||||
(import (scheme base))
|
(import (scheme base))
|
||||||
(begin
|
(begin
|
||||||
|
@ -11,6 +17,15 @@
|
||||||
(call-with-port (open-input-file string) proc))
|
(call-with-port (open-input-file string) proc))
|
||||||
(define (call-with-output-file string proc)
|
(define (call-with-output-file string proc)
|
||||||
(call-with-port (open-output-file string) proc))
|
(call-with-port (open-output-file string) proc))
|
||||||
TODO: with-input-from-file
|
(define (with-input-from-file string thunk) #f)
|
||||||
TODO: with-output-from-file
|
(define (with-output-to-file string thunk)
|
||||||
|
;; Have to do this the long way since parameterize is not available
|
||||||
|
(let ((old (current-output-port))
|
||||||
|
(new (current-output-port '<param-convert> (open-output-file string))))
|
||||||
|
(dynamic-wind
|
||||||
|
(lambda () (current-output-port '<param-set!> new))
|
||||||
|
thunk
|
||||||
|
(lambda ()
|
||||||
|
(close-port (current-output-port))
|
||||||
|
(current-output-port '<param-set!> old)))))
|
||||||
))
|
))
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
(import (scheme base)
|
(import (scheme base)
|
||||||
(scheme file))
|
(scheme file)
|
||||||
|
(scheme write))
|
||||||
|
|
||||||
(with-output-to-file
|
(with-output-to-file
|
||||||
"test.out"
|
"test.out"
|
||||||
|
|
Loading…
Add table
Reference in a new issue