/usr/local/lib/swipl/library/iostream.pl
All Application Manual Name SummaryHelp

  • swipl
    • library
      • error.pl
      • debug.pl
      • apply.pl
      • lists.pl
      • broadcast.pl
      • shlib.pl
      • option.pl
      • thread_pool.pl
      • gensym.pl
      • settings.pl
      • arithmetic.pl
      • main.pl
      • readutil.pl
      • operators.pl
      • pairs.pl
      • prolog_source.pl
      • record.pl
      • quasi_quotations.pl
      • pure_input.pl
      • solution_sequences.pl
      • ordsets.pl
      • random.pl
      • base64.pl
      • aggregate.pl -- Aggregation operators on backtrackable predicates
      • yall.pl
      • sandbox.pl -- Sandboxed Prolog code
      • apply_macros.pl -- Goal expansion rules to avoid meta-calling
      • assoc.pl
      • prolog_format.pl
      • predicate_options.pl
      • csv.pl
      • pprint.pl
      • atom.pl
      • modules.pl
      • occurs.pl -- Finding and counting sub-terms
      • prolog_xref.pl
      • prolog_colour.pl
      • lazy_lists.pl
      • ugraphs.pl
      • url.pl
      • www_browser.pl
      • prolog_pack.pl
      • git.pl
      • utf8.pl
      • dialect.pl
      • system.pl
      • terms.pl
      • date.pl
      • persistency.pl
      • iostream.pl -- Utilities to deal with streams
        • open_any/5
        • close_any/1
        • open_hook/6
      • prolog_stack.pl -- Examine the Prolog stack
      • edinburgh.pl
      • prolog_clause.pl
      • prolog_breakpoints.pl -- Manage Prolog break-points
      • wfs.pl
      • prolog_code.pl
      • sort.pl
      • dicts.pl
      • dif.pl
      • varnumbers.pl
      • pio.pl -- Pure I/O
      • thread.pl
      • nb_set.pl
      • edit.pl
      • backcomp.pl
      • strings.pl
      • base32.pl
      • charsio.pl
      • codesio.pl
      • coinduction.pl -- Co-Logic Programming
      • heaps.pl
      • rbtrees.pl
      • statistics.pl
      • when.pl
      • increval.pl
      • tables.pl
      • threadutil.pl -- Interactive thread utilities
      • ansi_term.pl
      • hashtable.pl
      • macros.pl
      • intercept.pl
      • prolog_metainference.pl
      • prolog_codewalk.pl -- Prolog code walker
      • fastrw.pl
      • prolog_coverage.pl
      • prolog_debug.pl
      • prolog_profile.pl -- Execution profiler
      • check.pl
      • prolog_autoload.pl
      • ctypes.pl -- Character code classification
      • writef.pl
      • prolog_versions.pl
      • explain.pl
      • listing.pl -- List programs and pretty print clauses
      • zip.pl
      • tty.pl
      • prolog_trace.pl
      • prolog_wrap.pl
      • make.pl -- Reload modified source files
      • files.pl
      • portray_text.pl
 open_any(+Specification, +Mode, -Stream, -Close, +Options)
Establish a stream from Specification that should be closed using Close, which can either be called or passed to close_any/1. Options processed:
encoding(Enc)
Set stream to encoding Enc.

Without loaded plugins, the open_any/5 processes the following values for Specification. If no rule matches, open_any/5 processes Specification as file(Specification).

Stream
A plain stream handle. Possisible post-processing options such as encoding are applied. Close does not close the stream, but resets other side-effects such as the encoding.
stream(Stream)
Same as a plain Stream.
FileURL
If Specification is of the form =file://...=, the pointed to file is opened using open/4. Requires library(uri) to be installed.
file(Path)
Explicitly open the file Path. Path can be an Path(File) term as accepted by absolute_file_name/3.
string(String)
Open a Prolog string, atom, list of characters or codes as an input stream.

The typical usage scenario is given in the code below, where <process> processes the input.

setup_call_cleanup(
    open_any(Spec, read, In, Close, Options),
    <process>(In),
    Close).

Currently, the following libraries extend this predicate:

library(http/http_open)
Adds support for URLs using the http and https schemes.