get-bytevector-all(3scm) Scheme Programmer's Manual get-bytevector-all(3scm)

get-bytevector-all - read bytes until the next end of file

(import (rnrs))                     ;R6RS
(import (rnrs io ports))            ;R6RS

(get-bytevector-all binary-input-port)

Reads all bytes until the next end of file, blocking as necessary.

If one or more bytes are read, returns a bytevector containing all bytes up to the next end of file and updates binary-input-port to point just past these bytes.

If no bytes are read, returns the end-of-file object.

The operation may block indefinitely waiting to see if more bytes will become available, even if some bytes are already available.

Returns a single value; a bytevector or the end-of-file object.

(call-with-port (open-file-input-port "/etc/machine-id")
  get-bytevector-all)

This procedure is a convenience that replaces a loop that is fiddly to make efficient and correct.

This procedure is unique to R6RS.

This procedure can raise exceptions with the following condition types:

&assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
&i/o-read (R6RS)
There was an I/O error during the read operation.
&i/o-port (R6RS)
This condition specifies the port object related to an &i/o-read condition.
The assertions described above are errors. Implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically.

get-bytevector-n(3scm),

R6RS

This procedure first appeared in the reworked I/O system in R6RS.

This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.

2023-02-01