Next: , Previous: Files and Ports, Up: Files and Ports


4.6.1 Opening and Closing

— Function: open-file string modes
— Function: try-open-file string modes

Returns a port capable of receiving or delivering characters as specified by the modes string. If a file cannot be opened #f is returned.

Internal functions opening files callback to the SCM function open-file. You can extend open-file by redefining it. try-open-file is the primitive procedure; Do not redefine try-open-file!

— Constant: open_read
— Constant: open_write
— Constant: open_both

Contain modes strings specifying that a file is to be opened for reading, writing, and both reading and writing respectively.

Both input and output functions can be used with io-ports. An end of file must be read or a two-argument file-position done on the port between a read operation and a write operation or vice-versa.

— Function: _ionbf modestr

Returns a version of modestr which when open-file is called with it as the second argument will return an unbuffered port. An input-port must be unbuffered in order for char-ready? and wait-for-input to work correctly on it. The initial value of (current-input-port) is unbuffered if the platform supports it.

— Function: _tracked modestr

Returns a version of modestr which when open-file is called with it as the second argument will return a tracked port. A tracked port maintains current line and column numbers, which may be queried with port-line and port-column.

— Function: _exclusive modestr

Returns a version of modestr which when open-file is called with it as the second argument will return a port only if the named file does not already exist. This functionality is provided by calling try-create-file See I/O-Extensions, which is not available for all platforms.

— Function: open-ports

Returns a list of all currently open ports, excluding string ports, see See String Ports. This may be useful after a fork See Posix Extensions, or for debugging. Bear in mind that ports that would be closed by gc will be kept open by a reference to this list.

— Function: close-port port

Closes port. The same as close-input-port and close-output-port.