(let* ((uri* (->uri* uri 'open-input-gfile))
(gfile (make-gfile uri*))
(gstream (gfile-read gfile))
- (port (make-generic-i/o-port (make-g-stream-source gstream) #f
+ (port (make-generic-i/o-port (make-binary-port
+ (make-g-stream-source gstream)
+ #f
+ 'open-input-gfile)
+ (default-object)
'open-input-gfile)))
;;(port/set-coding port 'ISO-8859-1)
;;(port/set-line-ending port 'NEWLINE)
(else (loop again (fix:1+ count)))))))
(define (make-g-stream-source gstream)
- ;; Not unlike make-non-channel-ss in genio.scm.
- (let ((port #f)
- (open? #t))
- (make-source/sink
- 'source
- #f
- (named-lambda (g-stream-source/get-port)
- port)
- (named-lambda (g-stream-source/set-port! port*)
- (set! port port*))
- (named-lambda (g-stream-source/open?)
- open?)
- (named-lambda (g-stream-source/close)
- (if open?
- (let ((value (g-input-stream-close gstream)))
- (set! open? #f)
- value)))
- (vector
+ (let ((open? #t))
+ (make-non-channel-input-source
(named-lambda (g-stream-source/has-bytes?)
#t)
- (named-lambda (g-stream-source/read-bytes buffer start end)
- (g-input-stream-read gstream buffer start end))))))
+ (named-lambda (g-stream-source/read-bytes! buffer start end)
+ (g-input-stream-read gstream buffer start end))
+ (named-lambda (g-stream-source/close)
+ (if open?
+ (let ((value (g-input-stream-close gstream)))
+ (set! open? #f)
+ value))))))
(define (open-output-gfile uri)
(let* ((uri* (->uri* uri 'open-output-gfile))
(gfile (make-gfile uri*))
(gstream (gfile-replace gfile #f #t 'private))
- (port (make-generic-i/o-port #f (make-g-stream-sink gstream)
+ (port (make-generic-i/o-port (make-binary-port
+ #f
+ (make-g-stream-sink gstream)
+ 'open-output-gfile)
+ (default-object)
'open-output-gfile)))
;;(port/set-coding port 'ISO-8859-1)
;;(port/set-line-ending port 'NEWLINE)
port))
(define (make-g-stream-sink gstream)
- ;; Not unlike make-non-channel-ss in genio.scm.
- (let ((port #f)
- (open? #t))
- (make-source/sink
- 'sink
- #f
- (named-lambda (g-stream-sink/get-port)
- port)
- (named-lambda (g-stream-sink/set-port! port*)
- (set! port port*))
- (named-lambda (g-stream-sink/open?)
- open?)
+ (let ((open? #t))
+ (make-non-channel-output-sink
+ (named-lambda (g-stream-sink/write-bytes buffer start end)
+ (g-output-stream-write gstream buffer start end))
(named-lambda (g-stream-sink/close)
(if open?
(let ((value (g-output-stream-close gstream)))
(set! open? #f)
- value)))
- (vector
- (named-lambda (g-stream-sink/write-bytes buffer start end)
- (g-output-stream-write gstream buffer start end))))))
+ value))))))
(define (gdirectory-read uri)
(let* ((uri* (->uri* uri 'gdirectory-read))
(define (mhash-update context bytes start end)
(guarantee-mhash-context context 'mhash-update)
- (subbytevector bytevector start end 'mhash-update)
+ (guarantee-subbytevector bytes start end 'mhash-update)
(with-context-locked-open context 'mhash-update
(lambda (alien)
- (C-call "do_mhash" alien bytevector start end))))
+ (C-call "do_mhash" alien bytes start end))))
(define (mhash-end context)
(with-context-locked-open context 'MHASH-END
(error:wrong-type-argument type "mhash type" 'mhash-keygen))
(let ((keygenid (mhash-keygen-type-id type))
(keyword-size (mhash-keygen-type-key-length type))
- (keyword (string->utf8 passphrase)))
+ (passbytes (string->utf8 passphrase)))
(let ((params (salted-keygen-params
keygenid (mhash-keygen-type-parameter-vector type) salt))
(keyword (make-bytevector keyword-size))
(let ((context (initialize)))
(let loop ()
(let ((n (read-bytevector! buffer input-port)))
- (if (and n (fix:> n 0))
+ (if (and n (not (eof-object? n)) (fix:> n 0))
(begin
(update context buffer 0 n)
(let ((n* (write-bytevector buffer output-port 0 n)))