Description
open( +atom, +atom, -stream, +stream_options )
open(Source, Mode, Stream, Options) succeeds if Source can be open in the mode Mode through the stream Stream. Source can be an atom with the path to a file or an HTML object (see the dom module). Mode is an atom indicating the opening mode, namely, read, write or append. The append mode opens the file for writing, setting the stream at the end of the file. Stream can be either a variable, in which case it will be bound to an integer value identifying the stream, or an atom, in which case it will be used to identify the stream. The available values for Options can be checked in the next section.
Options
open accepts a list of options as its last argument. These options are:
- type(T). Specifies if the stream is a text stream or a binary one. T can be either text or binary. If not specified, the stream is opened as a text stream.
- reposition(Bool). Specifies if the stream can be repositioned, i.e., if we can moved the stream to a certain point of the file. Bool can be either true or false.
- alias(A). Set A as the alias for the stream.
- eof_action(Action). Specifies what action must be performed when the end-of-file is reached. Action can be:
- error. A permision_error is raised.
- eof_code. The result of reading from the stream returns the end-of-file code.
- reset. The stream position is reset so it doesn't go past the end-of-file.
If the
Options list contains contradictory stream options, the rightmost stream option is the one which applies.