From 67a2276763f2cc30b6883313ee3ba93ec4219ae1 Mon Sep 17 00:00:00 2001 From: Rik van der Heijden Date: Sat, 2 Feb 2013 14:39:16 +0100 Subject: [PATCH] Backported dataAvailable to 2.4 --- lib/Cake/Console/ConsoleInput.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Cake/Console/ConsoleInput.php b/lib/Cake/Console/ConsoleInput.php index eb4928b38..3141a9356 100644 --- a/lib/Cake/Console/ConsoleInput.php +++ b/lib/Cake/Console/ConsoleInput.php @@ -48,4 +48,16 @@ class ConsoleInput { 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); + } + }