25 require_once
'PEAR.php';
26 require_once
'OLE.php';
80 if (
$options & STREAM_REPORT_ERRORS) {
81 trigger_error(
'Only reading is supported', E_USER_WARNING);
87 parse_str(substr(
$path, 25), $this->params);
88 if (!isset($this->params[
'oleInstanceId'],
89 $this->params[
'blockId'],
90 $GLOBALS[
'_OLE_INSTANCES'][$this->params[
'oleInstanceId']])) {
92 if (
$options & STREAM_REPORT_ERRORS) {
93 trigger_error(
'OLE stream not found', E_USER_WARNING);
97 $this->ole =
$GLOBALS[
'_OLE_INSTANCES'][$this->params[
'oleInstanceId']];
99 $blockId = $this->params[
'blockId'];
101 if (isset($this->params[
'size']) &&
102 $this->params[
'size'] < $this->ole->bigBlockThreshold &&
103 $blockId != $this->ole->root->_StartBlock) {
106 $rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock);
107 while ($blockId != -2) {
108 $pos = $rootPos + $blockId * $this->ole->bigBlockSize;
109 $blockId = $this->ole->sbat[$blockId];
110 fseek($this->ole->_file_handle,
$pos);
111 $this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
115 while ($blockId != -2) {
116 $pos = $this->ole->_getBlockOffset($blockId);
117 fseek($this->ole->_file_handle,
$pos);
118 $this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
119 $blockId = $this->ole->bbat[$blockId];
122 if (isset($this->params[
'size'])) {
123 $this->data = substr($this->data, 0, $this->params[
'size']);
153 $s = substr($this->data, $this->pos, $count);
154 $this->pos += $count;
164 $eof = $this->pos >= strlen($this->data);
166 if (version_compare(PHP_VERSION,
'5.0',
'>=') &&
167 version_compare(PHP_VERSION,
'5.1',
'<')) {
192 if ($whence == SEEK_SET && $offset >= 0) {
193 $this->pos = $offset;
194 } elseif ($whence == SEEK_CUR && -$offset <= $this->pos) {
195 $this->pos += $offset;
196 } elseif ($whence == SEEK_END && -$offset <=
sizeof($this->data)) {
197 $this->pos = strlen($this->data) + $offset;
212 'size' => strlen($this->data),