Stream utilities

Author(s): The Ciao Development Team.

This module implements a collection of predicates to read/write streams (or files) from/to several sources (lists of terms, strings, predicate output, etc.).

Documentation on exports

PREDICATEget_line/2

Usage:get_line(S,L)

Reads from Stream a line of text and unifies Line with it. The end of the line can have Unix [10] or Windows/DOS [13, 10] termination, which is not included in Line. At EOF, the term end_of_file is returned.

PREDICATEget_line/1

Usage:get_line(L)

Behaves like current_input(S), get_line(S,Line).

REGTYPEline/1
A regular type, defined as follows:
line(L) :-
    string(L).
line(end_of_file).

Usage:read_string_to_end(Stream,String)

Reads in String all the characters from Stream until an EOF is found.

  • The following properties should hold at call time:
    (stream_basic:stream/1)Stream is an open stream.
  • The following properties should hold upon exit:
    (basic_props:string/1)String is a string (a list of character codes).

Usage:read_bytes_to_end(Stream,Bytes)

Reads in Bytes all the bytes from Stream until an EOF is found.

Usage:discard_to_end(Stream)

Reads in all the bytes from Stream until an EOF is found.

PREDICATEread_bytes/3

Usage:read_bytes(Stream,N,Bytes)

Reads in Bytes at most N bytes from Stream, or until an EOF is found.

PREDICATEcopy_stream/3

Usage:copy_stream(InS,OutS,Copied)

Copies all bytes bytes (until EOF or error) from the InS stream into the OutS stream. The number of copied bytes is returned in Copied

Usage:write_string(Stream,String)

Writes String onto Stream.

Usage:write_string(String)

Behaves like current_input(S), write_string(S, String).

  • The following properties should hold at call time:
    (basic_props:string/1)String is a string (a list of character codes).

PREDICATEwrite_bytes/2

Usage:write_bytes(Stream,Bytes)

Writes Bytes onto Stream.

PREDICATEwrite_bytes/1

Usage:write_bytes(Bytes)

Behaves like current_input(S), write_bytes(S, Bytes).

Usage:file_to_string(FileName,String)

Reads all the characters from the file FileName and returns them in String.

Usage:string_to_file(String,FileName)

Reads all the characters from the string String and writes them to file FileName.

Usage:file_to_bytes(FileName,Bytes)

Reads all the bytes from the file FileName and returns them in Bytes.

Usage:bytes_to_file(Bytes,FileName)

Reads all the bytes from the bytes Bytes and writes them to file FileName.

No further documentation available for this predicate. Meta-predicate with arguments: output_to_file(goal,?).

PREDICATEopen_input/2

Usage:open_input(FileName,InputStreams)

PREDICATEclose_input/1

Usage:close_input(InputStreams)

PREDICATEopen_output/2

Usage:open_output(FileName,OutputStreams)

Usage:close_output(OutputStreams)

Documentation on imports

This module has the following direct dependencies: