Backported dataAvailable to 2.4

This commit is contained in:
Rik van der Heijden 2013-02-02 14:39:16 +01:00
parent 46aabbd6ae
commit 67a2276763

View file

@ -48,4 +48,16 @@ class ConsoleInput {
return fgets($this->_input); return fgets($this->_input);
} }
/**
* Checks if data is available on the stream
*
* @param integer $timeout An optional time to wait for data
* @return bool True for data available, false otherwise
*/
public function dataAvailable($timeout = 0) {
$readFds = array($this->_input);
$readyFds = stream_select($readFds, $writeFds, $errorFds, $timeout);
return ($readyFds > 0);
}
} }