YAP 7.1.0
open/4

open(+ F,+ M,- S,+ Opts) More...

Detailed Description

open(+ F,+ M,- S,+ Opts)

defined in the ISO standard

Opens the file with name F in mode M (read, write or append), returning S unified with the stream name, and following these options:

  • type(+ _T_) is iso

Specify whether the stream is a text stream (default), or a binary stream

  • reposition(+ _Bool_) is iso Specify whether it is possible to reposition the stream (true), or not (false) By default, YAP enables repositioning for all files, except terminal files and sockets
  • eof(+ _Action_) is iso

Specify the action to take if attempting to input characters from a stream where we have previously found an end_of_file The possible actions are error, that raises an error, reset, that tries to reset the stream and is used for tty type files, and eof_code, which generates a new end_of_file (default for non-tty files)

  • alias(+ _Name_) is iso

Specify an alias to the stream The alias Name must be an atom The alias can be used instead of the stream descriptor for every operation concerning the stream

The operation will fail and give an error if the alias name is already in use YAP allows several aliases for the same file, but only one is returned by stream_property/2

  • bom(+ _Bool_)

If present and true, a BOM (Byte Order Mark) was detected while opening the file for reading or a BOM was written while opening the stream See BOM for details

  • encoding(+ _Encoding_)

Set the encoding used for text See Encoding for an overview of wide character and encoding issues

  • representation_errors(+ _Mode_)

Change the behaviour when writing characters to the stream that cannot be represented by the encoding The behaviour is one of error (throw and Input/Output error exception), prolog (write \u...\ escape code or xml (write \&#...; XML character entity) The initial mode is prolog for the user streams and error for all other streams See also Encoding

  • expand_filename(+ _Mode_)

If Mode is true then do filename expansion, then ask Prolog to do file name expansion before actually trying to opening the file: this includes processing ~ characters and processing $ environment variables at the beginning of the file Otherwise, just try to open the file using the given name

The default behavior is given by the Prolog flag open_expands_filename

  • script( + _Boolean_ ) YAP extension

The file may be a Prolog script In read mode just check for initial lines if they start with the hash symbol, and skip them In write mode output an header that can be used to launch the file by calling yap -l file -- $* Note that YAP will not set file permissions as executable In append mode ignore the flag


The documentation for this class was generated from the following file: