### 2.3 Input/Output ¶

These procedures are provided by all implementations.

Function: file-exists? filename ¶

  Returns `#t` if the specified file exists. Otherwise, returns `#f`. If the underlying implementation does not support this feature then `#f` is always returned.

Function: delete-file filename ¶

  Deletes the file specified by filename. If filename can not be deleted, `#f` is returned. Otherwise, `#t` is returned.

Function: open-file filename modes ¶

  filename should be a string naming a file. `open-file` returns a port depending on the symbol modes:

  r

    an input port capable of delivering characters from the file.

  rb

    a binary input port capable of delivering characters from the file.

  w

    an output port capable of writing characters to a new file by that name.

  wb

    a binary output port capable of writing characters to a new file by that name.

  If an implementation does not distinguish between binary and non-binary files, then it must treat rb as r and wb as w.

  If the file cannot be opened, either #f is returned or an error is signalled. For output, if a file with the given name already exists, the effect is unspecified.

Function: port? obj ¶

  Returns `#t` if obj is an input or output port, otherwise returns `#f`.

Procedure: close-port port ¶

  Closes the file associated with port, rendering the port incapable of delivering or accepting characters.

  `close-file` has no effect if the file has already been closed. The value returned is unspecified.

Function: call-with-open-ports proc ports … ¶
Function: call-with-open-ports ports … proc ¶

  Proc should be a procedure that accepts as many arguments as there are ports passed to `call-with-open-ports`. `call-with-open-ports` calls proc with ports …. If proc returns, then the ports are closed automatically and the value yielded by the proc is returned. If proc does not return, then the ports will not be closed automatically unless it is possible to prove that the ports will never again be used for a read or write operation.

Function: tmpnam ¶

  Returns a pathname for a file which will likely not be used by any other process. Successive calls to `(tmpnam)` will return different pathnames.

Function: current-error-port ¶

  Returns the current port to which diagnostic and error output is directed.

Procedure: force-output ¶
Procedure: force-output port ¶

  Forces any pending output on port to be delivered to the output device and returns an unspecified value. The port argument may be omitted, in which case it defaults to the value returned by `(current-output-port)`.

Function: file-position port ¶
Function: file-position port #f ¶

  port must be open to a file. `file-position` returns the current position of the character in port which will next be read or written. If the implementation does not support file-position, then `#f` is returned.

Function: file-position port k ¶

  port must be open to a file. `file-position` sets the current position in port which will next be read or written. If successful, `#t` is returned; otherwise `file-position` returns `#f`.

Function: output-port-width ¶
Function: output-port-width port ¶

  Returns the width of port, which defaults to `(current-output-port)` if absent. If the width cannot be determined 79 is returned.

Function: output-port-height ¶
Function: output-port-height port ¶

  Returns the height of port, which defaults to `(current-output-port)` if absent. If the height cannot be determined 24 is returned.