mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-16 09:17:35 +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)
|
||||
(export
|
||||
call-with-input-file
|
||||
call-with-input-file
|
||||
call-with-output-file
|
||||
with-input-from-file
|
||||
with-output-from-file
|
||||
;delete-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))
|
||||
(begin
|
||||
|
@ -11,6 +17,15 @@
|
|||
(call-with-port (open-input-file string) proc))
|
||||
(define (call-with-output-file string proc)
|
||||
(call-with-port (open-output-file string) proc))
|
||||
TODO: with-input-from-file
|
||||
TODO: with-output-from-file
|
||||
(define (with-input-from-file string thunk) #f)
|
||||
(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)
|
||||
(scheme file))
|
||||
(scheme file)
|
||||
(scheme write))
|
||||
|
||||
(with-output-to-file
|
||||
"test.out"
|
||||
|
|
Loading…
Add table
Reference in a new issue