Skip to content

Commit

Permalink
Backported dataAvailable to 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Rik van der Heijden committed Feb 2, 2013
1 parent 46aabbd commit 67a2276
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Cake/Console/ConsoleInput.php
Expand Up @@ -48,4 +48,16 @@ public function read() {
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);
}

}

0 comments on commit 67a2276

Please sign in to comment.