A pliant stream is something in which you can write bytes or read bytes from. It can be a file, a TCP connection, or a filter to another stream.

method s open name [optionsflags
  arg_rw Stream s ; arg Str name [; arg Int options] ; arg Int flags

This is the current Pliant naming convention:
/path/subpath/... a file within Pliant tree
file:/path/subpath/... a file outside Pliant tree
tcp:/client/port
tcp://hostname/client/port
a TCP client connection.
tcp:/server/port a TCP server connection.
a FTP remote file. The 'lower' parameter specifies that the filenames provided by the server must be converted to lower case.
a Pliant remote file.
zlib:support_stream_name compress when writing, uncompress when reading.
These are the various open flags:
in opens for reading.
out opens for writing. If it's a file, it will be erased.
in+out opens for reading and writing: does not erase the file and sets the cursor at the beginning of the file.
append should be used with 'out'. Does not erase the file and sets the cursor at the end of the file.
safe should an Input/Output error occur on the stream, this will prevent the raise of an exception. Instead, it will mark the file as crashed and continue. Any further attempt to write will be ignored, and attempts to read will return as much zeros as requested.
mkdir if the stream attempts to write a file in a directory that does not exist, it will be created.
noautopost if you dont use this parameter, the output buffer is flushed each time you attempt to read more bytes from the stream than available in the input buffer.
seekmuch your application will change the file cursor often. Please remind that the Stream data type as not been designed for such an application and so the result will be poor even if you specify this parameter that may help Pliant Stream machinery to perform a bit better. For direct access, mapped file are much prefered that streams.
nocache
linecache the output should be flushed at the end of each ascii line.
bigcache the output buffer is 64Kb rather than 4Kb (these values may well change in the future)
cr end of line is carriage return (Macintosh style).
lf end of line is line feed return (Unix style). If no eol style is specified, this will be the default style when writing.
cr+lf end of line is line feed return (DOS, Windows style)
anyeol if no eol style is specified, it will be determined at the end of the first line. furthermore, if the 'anyeol' parameter is provided, then each line will be checked individually.

method s close
  arg_rw Stream s

Closes the stream.


method s raw_read address size
  arg_rw Stream s ; arg address address ; arg Int size

Reads 'size' bytes from the stream.

method s raw_write address size
  arg_rw Stream s ; arg address address ; arg Int size

Writes 'size' bytes to the stream.

method s read_available address size [maxi]
  arg_rw Stream s ; arg_w address address ; arg_w Int size [ ; arg Int maxi]

Attempts to put some bytes in the read buffer, then returns a pointer to it and how many bytes are available. The read cursor is also forwarded by that many bytes.
On return, size=0 means that the end of the file has been reached.

method s flush level
  arg_rw Stream s ; arg Int level

Flushes the output stream buffer.These are the various flush levels:
anytime the data has to be sent or written to the disk in less than an infinite time.
async the data has to be sent or written to the disk right now, but the command may return before it is completed.
sync the data has to be sent or written to the disk right now, and the command should lock until it is completed.

function raw_copy src dest mini maxi -> copyed
  arg_rw Stream src dest ; arg Int mini maxi copyed

Attempts to read some bytes from 'src' and write them on 'dest'.
The function will lock until either at least 'mini' bytes have been copied or one of the streams has crashed. In any case, it will not copy more than 'maxi' bytes.


method s atend -> e
 arg_rw Stream s ; arg CBool e

Tests if no more byte is available for reading.

method s is_open -> open
 arg_rw Stream s ; arg CBool open

Tests if the stream has been successfully opened.

method s is_crashed -> crashed
 arg_rw Stream s ; arg CBool crashed

Tests if the the stream as crashed.
The most common reasons for a stream to crash are:
. attempted to write to a file when no more disk space is available.
. attempted to read a file after end of file has been reached.
. attempted to read a write on a pipe after peer has closed the connection.


method s writechars string
  arg_rw Stream s ; arg Str string

Writes all the characters in 'string'

method s eol
  arg_rw Stream s

Writes carriage return, line feed or carriage return + line feed, depending on the stream open mode.

method s writeline string
  arg_rw Stream s ; arg Str string

Writes all the characters in 'string', followed by carriage return, line feed or carriage return + line feed, depending on the stream open mode.

method s readline -> line
  arg_rw Stream s ; arg Str line

Reads one line in the ascii file.
If the end of the file as been reached, an empty string will be returned.


method s query question -> answer
  arg_rw Stream s ; arg Str question answer

method s configure command -> status
  arg_rw Stream s ; arg Str command ; arg Status status