#include <UTCommandInputStream.h>
Public Member Functions | |
CommandInputStream_t () | |
virtual | ~CommandInputStream_t () |
bool | Execute (const utf8 *command) |
bool | Execute (stringliteral *command) |
bool | Execute (const String_t &command) |
virtual Status_t | Read (byte *buffer, int bytes_to_read, bool force_read_all=true) |
virtual Status_t | ReadLine (out String_t *line) |
virtual Status_t | Peek (byte *buffer, int bytes_to_read) |
virtual Status_t | Position (out fileoff_t *position) |
virtual Status_t | Seek (fileoff_t position) |
virtual Status_t | Close () |
int | ExitStatus () |
Executes a shell command and pipes its output to this input stream for reading. It would be nice if this had an input stream and output stream, but the standard popen command accepts only "r" or "w".
Definition at line 42 of file UTCommandInputStream.h.
CommandInputStream_t::CommandInputStream_t | ( | ) |
Command input stream constructor. The command must be initiated using the Execute function.
virtual CommandInputStream_t::~CommandInputStream_t | ( | ) | [virtual] |
Command input stream destructor. If a command has been executed, it must have been completed by calling Close or an error must have occurred in a Read or Seek operation.
bool CommandInputStream_t::Execute | ( | const utf8 * | command | ) | [inline] |
Executes the specified command. This function does not return Status_t, as would normally be appropriate, because the standard popen command does not guarantee that errno will be set.
Definition at line 163 of file UTCommandInputStream.h.
bool CommandInputStream_t::Execute | ( | stringliteral * | command | ) | [inline] |
Executes the specified command. This function does not return Status_t, as would normally be appropriate, because the standard popen command does not guarantee that errno will be set.
Definition at line 170 of file UTCommandInputStream.h.
bool CommandInputStream_t::Execute | ( | const String_t & | command | ) |
Executes the specified command. This function does not return Status_t, as would normally be appropriate, because the standard popen command does not guarantee that errno will be set.
virtual Status_t CommandInputStream_t::Read | ( | byte * | buffer, | |
int | bytes_to_read, | |||
bool | force_read_all = true | |||
) | [virtual] |
Reads from the command's stdout. The ReadLine function, provided by the InputStream_t base class, is available too. Asynchronous reads are not supported, although with force_read_all false, the function may return fewer than bytes_to_read before the end of the file is reached if the underlying fread returns less than the requested byte count.
Implements InputStream_t.
Reads a line from the command's stdout. The line will end when "\r", "\n", "\r\n", "\0", or the end of the stream is encountered. The returned line string will not contain the terminator. If the end of the stream is reached with no line having been read, ReadLine returns eERR_end_of_file.
Reimplemented from InputStream_t.
Reads up to bytes_to_read bytes into buffer, and returns the number of bytes read as a success status indication, or an error status. Unlike the Read function, the current position is unaffected, and the same data would be returned by a subsequent call to Peek or Read.
Reimplemented from InputStream_t.
Returns the number of bytes read from the command's stdout through the position output parameter unless an error occurs, in which case an error status is returned in the Status_t return value. For command output streams of infinite length with a signed fileoff_t type on the target platform, negative values are legitimate, with the largest negative value representing wraparound from the largest positive value.
Implements InputStream_t.
Repositions the input stream to the requested position. This type of stream does not support seeking backward. Seeking forward will simply discard bytes from the stream. For command output streams of infinite length with a signed fileoff_t type on the target platform, negative values are legitimate, with the largest negative value representing wraparound from the largest positive value.
Implements InputStream_t.
virtual Status_t CommandInputStream_t::Close | ( | ) | [virtual] |
Closes the executing or executed command. Returns a success status if the command had an exit status of 0. Returns a failure status if the exit status was anything else, or some other error occurred. After calling close, the exit status of the command can be obtained by calling ExitStatus.
Implements InputStream_t.
int CommandInputStream_t::ExitStatus | ( | ) |
Returns the specific exit status returned by the child process when Close was called.