. */ require_once 'phing/system/io/InputStream.php'; require_once 'phing/system/io/PhingFile.php'; /** * Input stream subclass for file streams. * * @package phing.system.io */ class FileInputStream extends InputStream { /** * @var PhingFile The associated file. */ protected $file; /** * Construct a new FileInputStream. * @param mixed $file * @throws Exception - if invalid argument specified. * @throws IOException - if unable to open file. */ public function __construct($file, $append = false) { if ($file instanceof PhingFile) { $this->file = $file; } elseif (is_string($file)) { $this->file = new PhingFile($file); } else { throw new Exception("Invalid argument type for \$file."); } $stream = @fopen($this->file->getAbsolutePath(), "rb"); if ($stream === false) { throw new IOException("Unable to open " . $this->file->__toString() . " for reading: " . $php_errormsg); } parent::__construct($stream); } /** * Returns a string representation of the attached file. * @return string */ public function __toString() { return $this->file->getPath(); } /** * Mark is supported by FileInputStream. * @return boolean TRUE */ public function markSupported() { return true; } }