[previous] [up] [next]     [index]
Next: Pipes Up: Ports Previous: Current Ports

Opening File Ports

The open-input-file and open-output-file procedures accept an optional flag argument after the filename that specifies a mode for the file:

The open-output-file procedure can also take a flag argument that specifies how to proceed when a file with the specified name already exists:

If the 'update flag is specified and the file does not exist, an exception is raised.

Extra flag arguments are passed to open-output-file in any order. Appropriate flag arguments can also be passed as the last argument(s) to call-with-input-file, with-input-from-file, call-with-output-file, and with-output-to-file. When conflicting flag arguments (e.g., both 'error and 'replace) are provided to open-output-file, with-output-to-file, or call-with-output-file, the exn:application:mismatch exception is raised.

Both with-input-from-file and with-output-to-file close the ports they create if control jumps out of the supplied thunk (either through a continuation or an exception). The port remains closed if control jumps back into the thunk.

When an input or output file-stream port is created, it is placed into the management of the current custodian (see section 9.5).


[previous] [up] [next]     [index]
Next: Pipes Up: Ports Previous: Current Ports

PLT