[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.18.2 Common port operations

Function: port? obj
Function: input-port? obj
Function: output-port? obj
[R5RS] Returns true if obj is a port, an input port and an output port, respectively. Port? is not listed in the R5RS standard procedures, but mentioned in the "Disjointness of Types" section.

Function: port-closed? port
Returns true if obj is a port and it is already closed. A closed port can't be reopened.

Function: current-input-port
Function: current-output-port
[R5RS] Returns the current input port and the current output port, respectively.

Function: current-error-port
Returns the current output port.

Function: standard-input-port
Function: standard-output-port
Function: standard-error-port
Returns ports that are bound initially to current input, output and error port, respectively.

Function: with-input-from-port port thunk
Function: with-output-to-port port thunk
Function: with-error-to-port port thunk
Calls thunk. During evaluation of thunk, the current input port, current output port and current error port are set to port, respectively.

Function: close-input-port port
Function: close-output-port port
[R5RS] Closes input and output port, respectively

Function: port-type port
Returns the type of port in one of the symbols file, string or proc.

Function: port-name port
Returns the name of port. If the port is associated to a file, it is the name of the file. Otherwise, it is some description of the port.

Function: port-buffering port
Function: (setter port-buffering) port buffering-mode
If port is type of file port (i.e. (port-type port) returns file), these procedures gets and sets the port's buffering mode. For input ports, the port buffering mode may be either one of :full, :modest or :none. For output ports, port-buffering, it may be one of :full, :line or :none. See section 6.18.3 File ports, for explanation of those modes.

If port-buffering is applied to ports other than file ports, it returns #f. If the setter of port-buffering is applied to ports other than file ports, it signals an error.

Function: port-current-line port
Returns the current line count of port. This information is only available on file-based port, and as long as you're doing sequential character I/O on it. Otherwise, this returns -1.

Function: port-file-number port
Returns an integer file descriptor, if the port is associated to the system file I/O. Returns #f otherwise.

Function: copy-port src dst &keyword (unit 0)
Copies data from an input port src to an output port dst, until eof is read from src.

The keyword argument unit may be zero, a positive exact integer, a symbol byte or a symbol char, to specify the unit of copying. If it is an integer, a buffer of the size (in case of zero, a system default size) is used to copy, using block I/O. Generally it is the fastest if you copy between normal files. If unit is a symbol byte, the copying is done byte by byte, using C-verson of read-byte and write-byte. If unit is a symbol char, the copying is done character by character, using C-version of read-char and write-char.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by Ken Dickey on November, 28 2002 using texi2html