open-file-input-port - open a file for reading
(import (rnrs)) ;R6RS
(import (rnrs io ports)) ;R6RS
(open-file-input-port filename file-options)
(open-file-input-port filename file-options buffer-mode)
(open-file-input-port filename file-options buffer-mode maybe-transcoder)
Returns an input port for the named file.
argument defaults to the value of (file-options).
Note that the standard file options do nothing for input ports.
argument must be one of the symbols that name a buffer mode. It
Note that line buffering is unlikely to be effective on input ports.
- Textual ports
is a transcoder, it becomes the transcoder associated with the
The port will then be a textual port.
- Binary ports
If maybe-transcoder is
or absent, the port will be a binary port.
- Port positioning
The port will support the
operations if it is a binary port. Otherwise support is
implementation-dependent, and possibly transcoder-dependent.
Returns a single value; a binary or textual input port.
;; Return all records in /etc/passwd
(let lp ()
(let ((line (get-line p)))
(if (eof-object? line)
(cons line (lp)))))))
This is used in applications that open binary files, and ones that
open textual files while needing control over the transcoder.
This procedure is unique to R6RS. Other RnRS revisions have
which is also in 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.
must be either a transcoder or
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.
First appeared in the reworked I/O system in R6RS.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
Markup created by unroff 1.0sc, March 04, 2023.