Next: , Previous: , Up: stdlib io port   [Index]


5.8.2.2 File options

When opening a file, the various procedures in this library accept a file-options object that encapsulates flags to specify how the file is to be opened. A file-options object is an enum–set over the symbols constituting valid file options. A file-options parameter name means that the corresponding argument must be a file–options object.

Syntax: file-options ?file-options-symbol

Each ?file-options-symbol must be a symbol. The file-options syntax returns a file–options object that encapsulates the specified options.

When supplied to an operation that opens a file for output, the file–options object returned by (file-options) (without arguments) specifies that the file is created if it does not exist and an exception with condition type &i/o-file-already-exists is raised if it does exist. The following standard options can be included to modify the default behavior.

no-create

If the file does not already exist, it is not created; instead, an exception with condition type &i/o-file-does-not-exist is raised. If the file already exists, the exception with condition type &i/o-file-already-exists is not raised and the file is truncated to zero length.

no-fail

If the file already exists, the exception with condition type &i/o-file-already-exists is not raised, even if no-create is not included, and the file is truncated to zero length.

no-truncate

If the file already exists and the exception with condition type &i/o-file-already-exists has been inhibited by inclusion of no-create or no-fail, the file is not truncated, but the port’s current position is still set to the beginning of the file.

These options have no effect when a file is opened only for input. Symbols other than those listed above may be used as ?file-options-symbols; they have implementation–specific meaning, if any.

NOTE Only the name of ?file-options-symbol is significant.


Next: , Previous: , Up: stdlib io port   [Index]