home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / php / PEAR / phing / system / io / InputStreamReader.php < prev    next >
Encoding:
PHP Script  |  2007-08-28  |  3.7 KB  |  127 lines

  1. <?php
  2. /*
  3.  *  $Id: FileReader.php 123 2006-09-14 20:19:08Z mrook $
  4.  *
  5.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  6.  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  7.  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  8.  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  9.  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  10.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  11.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  12.  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  13.  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  14.  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  15.  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  16.  *
  17.  * This software consists of voluntary contributions made by many individuals
  18.  * and is licensed under the LGPL. For more information please see
  19.  * <http://phing.info>. 
  20.  */
  21.  
  22. include_once 'phing/system/io/PhingFile.php';
  23. include_once 'phing/system/io/Reader.php';
  24.  
  25. /**
  26.  * Writer class for OutputStream objects.
  27.  * 
  28.  * Unlike the Java counterpart, this class does not (yet) handle
  29.  * character set transformations.  This will be an important function
  30.  * of this class with move to supporting PHP6.
  31.  *  * @package   phing.system.io
  32.  */
  33. class InputStreamReader extends Reader {
  34.     
  35.     /**
  36.      * @var InputStream
  37.      */
  38.     protected $inStream;
  39.     
  40.     /**
  41.      * Construct a new InputStreamReader.
  42.      * @param InputStream $$inStream InputStream to read from
  43.      */
  44.     public function __construct(InputStream $inStream) {
  45.         $this->inStream = $inStream;
  46.     }
  47.     
  48.     /**
  49.      * Close the stream.
  50.      */
  51.     public function close() {
  52.         return $this->inStream->close();
  53.     }
  54.     
  55.     /**
  56.      * Skip over $n bytes.
  57.      * @param int $n
  58.      */
  59.     public function skip($n) {
  60.         return $this->inStream->skip($n);
  61.     }
  62.     
  63.     /**
  64.      * Read data from file.
  65.      * @param int $len Num chars to read.
  66.      * @return string chars read or -1 if eof.
  67.      */
  68.     public function read($len = null) {
  69.         return $this->inStream->read($len);
  70.     }
  71.     
  72.     /**
  73.      * Marks the current position in this input stream.
  74.      * @throws IOException - if the underlying stream doesn't support this method.
  75.      */
  76.     public function mark() {
  77.         $this->inStream->mark();
  78.     }
  79.     
  80.     /**
  81.      * Whether the attached stream supports mark/reset.
  82.      * @return boolean
  83.      */
  84.     public function markSupported() {
  85.         return $this->inStream->markSupported();
  86.     }
  87.     
  88.     /**
  89.      * Repositions this stream to the position at the time the mark method was last called on this input stream.
  90.      * @throws IOException - if the underlying stream doesn't support this method.
  91.      */
  92.     public function reset() {
  93.         $this->inStream->reset();
  94.     }
  95.  
  96.     /**
  97.      * Whether eof has been reached with stream.
  98.      * @return boolean
  99.      */
  100.     public function eof() {
  101.         return $this->inStream->eof();
  102.     }
  103.      
  104.     /**
  105.      * Reads a entire file and stores the data in the variable
  106.      * passed by reference.
  107.      *
  108.      * @param    string $file    String. Path and/or name of file to read.
  109.      * @param    object &$rBuffer    Reference. Variable of where to put contents.
  110.      *
  111.      * @return    TRUE on success. Err object on failure.
  112.      * @author  Charlie Killian, charlie@tizac.com
  113.      * @deprecated Use read() or BufferedReader instead.
  114.      */
  115.     public function readInto(&$rBuffer) {
  116.         return $this->inStream->readInto($rBuffer);
  117.     }
  118.     
  119.     /**
  120.      * Returns string representation of attached stream.
  121.      * @return string
  122.      */
  123.     public function getResource() {
  124.         return $this->inStream->__toString();
  125.     }
  126. }
  127.