\MailSo\Mime\Enumerations\Constants::LINE_LENGTH, 'line-break-chars' => \MailSo\Mime\Enumerations\Constants::CRLF )); return \is_resource($rFilter) ? $rStream : false; } self::$aStreams[$sHashName] = array($rStream, $sUtilsDecodeOrEncodeFunctionName, $sFromEncoding, $sToEncoding); \MailSo\Base\Loader::IncStatistic('CreateStream/Binary'); return \fopen(self::STREAM_NAME.'://'.$sHashName, 'rb'); } /** * @param string $sPath * * @return bool */ public function stream_open($sPath) { $this->iPos = 0; $this->sBuffer = ''; $this->sReadEndBuffer = ''; $this->rStream = false; $this->sFromEncoding = null; $this->sToEncoding = null; $this->sFunctionName = null; $bResult = false; $aPath = parse_url($sPath); if (isset($aPath['host']) && isset($aPath['scheme']) && 0 < strlen($aPath['host']) && 0 < strlen($aPath['scheme']) && self::STREAM_NAME === $aPath['scheme']) { $sHashName = $aPath['host']; if (isset(self::$aStreams[$sHashName]) && is_array(self::$aStreams[$sHashName]) && 4 === count(self::$aStreams[$sHashName])) { $this->rStream = self::$aStreams[$sHashName][0]; $this->sFunctionName = self::$aStreams[$sHashName][1]; $this->sFromEncoding = self::$aStreams[$sHashName][2]; $this->sToEncoding = self::$aStreams[$sHashName][3]; } $bResult = is_resource($this->rStream); } return $bResult; } /** * @param int $iCount * * @return string */ public function stream_read($iCount) { $sReturn = ''; $sFunctionName = $this->sFunctionName; if ($iCount > 0) { if ($iCount < strlen($this->sBuffer)) { $sReturn = substr($this->sBuffer, 0, $iCount); $this->sBuffer = substr($this->sBuffer, $iCount); } else { $sReturn = $this->sBuffer; while ($iCount > 0) { if (feof($this->rStream)) { if (0 === strlen($this->sBuffer.$sReturn)) { return false; } if (0 < strlen($this->sReadEndBuffer)) { $sReturn .= self::$sFunctionName($this->sReadEndBuffer, $this->sReadEndBuffer, $this->sFromEncoding, $this->sToEncoding); $iDecodeLen = strlen($sReturn); } $iCount = 0; $this->sBuffer = ''; } else { $sReadResult = fread($this->rStream, 8192); if (false === $sReadResult) { return false; } $sReturn .= self::$sFunctionName($this->sReadEndBuffer.$sReadResult, $this->sReadEndBuffer, $this->sFromEncoding, $this->sToEncoding); $iDecodeLen = strlen($sReturn); if ($iCount < $iDecodeLen) { $this->sBuffer = substr($sReturn, $iCount); $sReturn = substr($sReturn, 0, $iCount); $iCount = 0; } else { $iCount -= $iDecodeLen; } } } } $this->iPos += strlen($sReturn); return $sReturn; } return false; } /** * @return int */ public function stream_write() { return 0; } /** * @return int */ public function stream_tell() { return $this->iPos; } /** * @return bool */ public function stream_eof() { return 0 === strlen($this->sBuffer) && feof($this->rStream); } /** * * @return array */ public function stream_stat() { return array( 'dev' => 2, 'ino' => 0, 'mode' => 33206, 'nlink' => 1, 'uid' => 0, 'gid' => 0, 'rdev' => 2, 'size' => 0, 'atime' => 1061067181, 'mtime' => 1056136526, 'ctime' => 1056136526, 'blksize' => -1, 'blocks' => -1 ); } /** * @return bool */ public function stream_seek() { return false; } }