Skip to content

Commit

Permalink
Added dataAvailable method for ConsoleInput
Browse files Browse the repository at this point in the history
  • Loading branch information
Rik van der Heijden committed Dec 12, 2012
1 parent ccde7e8 commit 060f090
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Cake/Console/ConsoleInput.php
Expand Up @@ -50,4 +50,16 @@ public function read() {
return fgets($this->_input);
}

/**
* Check if data is available on stdin
*
* @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, $w = null, $e = null, $timeout);
return ($readyFds > 0)
}

}

0 comments on commit 060f090

Please sign in to comment.