/** * Open the stream and return the associated resource. * * @access protected * @param string $streamName Stream name (e.g. path or URL). * @param \Hoa\Stream\Context $context Context. * @return resource * @throw \Hoa\File\Exception\FileDoesNotExist * @throw \Hoa\File\Exception */ protected function &_open($streamName, \Hoa\Stream\Context $context = null) { static $createModes = array(parent::MODE_READ); if (!in_array($this->getMode(), $createModes)) { throw new Exception('Open mode are not supported; given %d. Only %s are supported.', 0, array($this->getMode(), implode(', ', $createModes))); } preg_match('#^(\\w+)://#', $streamName, $match); if ((isset($match[1]) && $match[1] == 'file' || !isset($match[1])) && !file_exists($streamName)) { throw new Exception\FileDoesNotExist('File %s does not exist.', 1, $streamName); } $out = parent::_open($streamName, $context); return $out; }