An InputSource
is an object from which bytes can be
read, i.e. just like Open.file
in read mode. However the
actual data can be obtained from a number of arbitrary sources like
files, urls or virtual strings as if they had been lazily
concatenated. For example:
functor
import
InputSource at 'x-ozlib://duchier/op/InputSource.ozf'
define
...
F = {New InputSource.'class'
init([file(FILE1) url(URL2) vs(VS3)])}
...
end
F
will behave as if the data in file FILE1
,
in document at url URL2
, and in virtual string
VS3
had been lazily concatenated. This data can be read
using the read
method as in Open.file
This package can be installed by following the usual
configure, build, install procedure, i.e. by executing a the
shell:
./configure
make install
By default, all files of the package are
installed in the user's ~/.oz directory tree. In
particular, all modules are installed in the user's private cache.
You can check the automatically generated API produced by ozh. However in brief:
init(Specs)
Specs
is a list of specs. Each spec if either
a file name or url, or more explicitly a record whose label indicates
the type of source:
files(S)
files([S1 ... Sn])
url(S)
urls([S1 ... Sn])
vs(S)
string(S)
read(list:L tail:T<=nil size:S<=1024 len:N<=_)
Open
get($)
nil
only when the source is exhausted. It is equivalent to read(list:$)
close()
{New InputSource.'class' init(Specs)}
Specs
is
a list of specs as described above.
{New InputSource.file init(File)}
{New InputSource.files init([File1 ... FileN])}
{New InputSource.url init(URL)}
{New InputSource.urls init([URL1 ... URLN])}
{New InputSource.vs init(VS)}
{New InputSource.string init(VS)}