Permalink
Browse files

Backported dataAvailable to 2.4

  • Loading branch information...
1 parent 46aabbd commit 67a2276763f2cc30b6883313ee3ba93ec4219ae1 Rik van der Heijden committed Feb 2, 2013
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/Cake/Console/ConsoleInput.php
@@ -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.