Unit implementing pipe streams.

The Pipes unit implements streams that are wrappers around the OS's pipe functionality. It creates a pair of streams, and what is written to one stream can be read from another.

uses for exception support. Used for the TSTream class definition. Exception raised when an invalid operation is performed on a pipe stream. Exception raised when an invalid seek operation is attempted on a pipe. Exception raised when an error occurred during the creation of a pipe pair. TStream descendent which wraps the read end of a pipe. TInputPipeStream is created by the call to represent the reading end of a pipe. It is a TStream descendent which does not allow writing, and which mimics the seek operation. TStream Write data to the stream. Write overrides the parent implementation of Write. On a TInputPipeStream will always raise an exception, as the pipe is read-only. An EStreamError exception is raised when this function is called. Read Seek Number of bytes actually written. Memory buffer containing the data to be written. Number of bytes that must be written. Set the current position of the stream

Seek overrides the standard Seek implementation. Normally, pipe streams stderr are not seekable. The TInputPipeStream stream tries to provide seek capabilities for the following limited number of cases:

Origin=soFromBeginning
If Offset is larger than the current position, then the remaining bytes are skipped by reading them from the stream and discarding them.
Origin=soFromCurrent
If Offset is zero, the current position is returned. If it is positive, then Offset bytes are skipped by reading them from the stream and discarding them, if the stream is of type iosInput.

All other cases will result in a EPipeSeek exception.

An exception is raised if the stream does not allow the requested seek operation. Seek
New position of the stream. Offset, in bytes, starting at Origin Where to start counting Offset bytes. Read data from the stream to a buffer. Read calls the inherited read and adjusts the internal position pointer of the stream. None. Write Seek Number of bytes actually read from the stream. Memory buffer where to write the data read from the stream. Number of bytes to read from the stream. Number of bytes available for reading.

NumBytesAvailable is the number of bytes available for reading. This is the number of bytes in the OS buffer for the pipe. It is not a number of bytes in an internal buffer.

If this number is nonzero, then reading NumBytesAvailable bytes from the stream will not block the process. Reading more than NumBytesAvailable bytes will block the process, while it waits for the requested number of bytes to become available.

TStream descendent which wraps the write end of a pipe. TOutputPipeStream is created by the call to represent the writing end of a pipe. It is a TStream descendent which does not allow reading. TStream Sets the position in the stream Seek is overridden in TOutputPipeStream. Calling this method will always raise an exception: an output pipe is not seekable. An exception is raised if this method is called. New position of the stream. Offset, in bytes, starting at Origin Where to start counting Offset bytes. Read data from the stream. Read overrides the parent Read implementation. It always raises an exception, because a output pipe is write-only. An EStreamError exception is raised when this function is called. Seek Number of bytes actually read from the stream. Memory buffer where to write the data read from the stream. Number of bytes to read from the stream. Function to create a set of pipe handles CreatePipeHandles provides an OS-independent way to create a set of pipe filehandles. These handles are inheritable to child processes. The reading end of the pipe is returned in InHandle, the writing end in OutHandle. On error, False is returned. True if the call was succesul, False if not. File handle for reading end of the pipe File handle for writing end of the pipe Create a pair of pipe stream.

CreatePipeStreams creates a set of pipe file descriptors with , and if that call is succesfull, a pair of streams is created: InPipe and OutPipe.

On some systems (notably: windows) the size of the buffer to be used for communication between 2 ends of the buffer can be specified in the parameter. This parameter is ignored on systems that do not support setting the buffer size.

If no pipe handles could be created, an exception is raised.
Contains the read end of the pipe on return Contains the write end of the pipe on return. Constant used in EPipeCreation exception. Constant used in EPipeSeek exception. Exception support Stream definitions Destroy this instance of the input pipe stream Destroy overrides the destructor to close the pipe handle, prior to calling the inherited destructor. None Destroy this instance of the output pipe stream Destroy overrides the destructor to close the pipe handle, prior to calling the inherited destructor. None Buffer size to be used for the pipe