Next: , Previous: Line/Delimited, Up: Input and Output


27.8 Block reading and writing

The Block-string-I/O module can be accessed with:

     (use-modules (ice-9 rw))

It currently contains procedures that help to implement the (scsh rw) module in guile-scsh.

— Scheme Procedure: read-string!/partial str [port/fdes [start [end]]]
— C Function: scm_read_string_x_partial (str, port/fdes, start, end)

Read characters from port/fdes into a string str. A port must have an underlying file descriptor — a so-called fport. This procedure is scsh-compatible and can efficiently read large strings. It will:

— Scheme Procedure: read-string!/partial/never-fewer buf port rd-offset len wr-offset

Read len bytes into string buf starting at wr-offset, from port starting at rd-offset. If rd-offset is #f, use the current position. If rd-offset is an integer, port must be seekable. This proc is basically a loop around read-string!/partial.

— Scheme Procedure: write-string/partial str [port/fdes [start [end]]]
— C Function: scm_write_string_partial (str, port/fdes, start, end)

Write characters from a string str to port/fdes. A port must have an underlying file descriptor — a so-called fport. This procedure is scsh-compatible and can efficiently write large strings. It will:

— Scheme Procedure: write-string/partial/never-fewer str [port/fdes [start [end]]]

Like write-string/partial, except that if fewer bytes than specified (that is, endstart) are written, loop until all of them are indeed output.