[gambit-list] I seem unable to grasp I/O...
Alex Queiroz
asandroq at gmail.com
Mon May 11 22:30:27 EDT 2009
Hallo,
Why does this code always return the output vector, instead of
whatever I put inside the inner 'if'?
(define (embed-resource file)
(let* ((buffer-size 4096)
(buffer (make-u8vector buffer-size 0))
(out-vector (make-u8vector 0))
(info (file-info file)))
(if (eq? (file-info-type info) 'regular)
(call-with-input-file file
(lambda (in)
(call-with-output-u8vector out-vector
(lambda (out)
(let loop ()
(let ((size (read-subu8vector buffer 0 buffer-size in)))
(write-subu8vector buffer 0 size out)
(if (< size buffer-size)
`(define
,(string->symbol (path-strip-extension file)))
(loop))))))))
(error "bad file" file))))
Cheers,
--
-alex
http://www.ventonegro.org/
More information about the Gambit-list
mailing list