ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
OLE_ChainedBlockStream Class Reference
+ Inheritance diagram for OLE_ChainedBlockStream:
+ Collaboration diagram for OLE_ChainedBlockStream:

Public Member Functions

 stream_open ($path, $mode, $options, &$openedPath)
 Implements support for fopen(). More...
 
 stream_close ()
 Implements support for fclose(). More...
 
 stream_read ($count)
 Implements support for fread(), fgets() etc. More...
 
 stream_eof ()
 Implements support for feof(). More...
 
 stream_tell ()
 Returns the position of the file pointer, i.e. More...
 
 stream_seek ($offset, $whence)
 Implements support for fseek(). More...
 
 stream_stat ()
 Implements support for fstat(). More...
 
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor. More...
 
 _PEAR ()
 Destructor (the emulated type of...). More...
 
getStaticProperty ($class, $var)
 If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. More...
 
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes. More...
 
 isError ($data, $code=null)
 Tell whether a value is a PEAR error. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled. More...
 
 expectError ($code=' *')
 This method is used to tell which errors you expect to get. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available. More...
 
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack. More...
 
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
 This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. More...
 
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options. More...
 
 staticPushErrorHandling ($mode, $options=null)
 
 staticPopErrorHandling ()
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 loadExtension ($ext)
 OS independant PHP extension load. More...
 

Data Fields

 $ole
 
 $params
 
 $data
 
 $pos
 
- Data Fields inherited from PEAR
 $_debug = false
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_default_error_handler = ''
 
 $_error_class = 'PEAR_Error'
 
 $_expected_errors = array()
 

Detailed Description

Definition at line 41 of file ChainedBlockStream.php.

Member Function Documentation

◆ stream_close()

OLE_ChainedBlockStream::stream_close ( )

Implements support for fclose().

Returns
string

Definition at line 137 of file ChainedBlockStream.php.

References $GLOBALS.

138  {
139  $this->ole = null;
140  unset($GLOBALS['_OLE_INSTANCES']);
141  }
$GLOBALS['ct_recipient']

◆ stream_eof()

OLE_ChainedBlockStream::stream_eof ( )

Implements support for feof().

Returns
bool TRUE if the file pointer is at EOF; otherwise FALSE

Definition at line 162 of file ChainedBlockStream.php.

Referenced by stream_read().

163  {
164  $eof = $this->pos >= strlen($this->data);
165  // Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508
166  if (version_compare(PHP_VERSION, '5.0', '>=') &&
167  version_compare(PHP_VERSION, '5.1', '<')) {
168 
169  $eof = !$eof;
170  }
171  return $eof;
172  }
+ Here is the caller graph for this function:

◆ stream_open()

OLE_ChainedBlockStream::stream_open (   $path,
  $mode,
  $options,
$openedPath 
)

Implements support for fopen().

For creating streams using this wrapper, use OLE_PPS_File::getStream().

Parameters
stringresource name including scheme, e.g. ole-chainedblockstream://oleInstanceId=1
stringonly "r" is supported
intmask of STREAM_REPORT_ERRORS and STREAM_USE_PATH
stringabsolute path of the opened stream (out parameter)
Returns
bool true on success

Definition at line 77 of file ChainedBlockStream.php.

References $GLOBALS, $options, and $path.

78  {
79  if ($mode != 'r') {
80  if ($options & STREAM_REPORT_ERRORS) {
81  trigger_error('Only reading is supported', E_USER_WARNING);
82  }
83  return false;
84  }
85 
86  // 25 is length of "ole-chainedblockstream://"
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']])) {
91 
92  if ($options & STREAM_REPORT_ERRORS) {
93  trigger_error('OLE stream not found', E_USER_WARNING);
94  }
95  return false;
96  }
97  $this->ole = $GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']];
98 
99  $blockId = $this->params['blockId'];
100  $this->data = '';
101  if (isset($this->params['size']) &&
102  $this->params['size'] < $this->ole->bigBlockThreshold &&
103  $blockId != $this->ole->root->_StartBlock) {
104 
105  // Block id refers to small blocks
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);
112  }
113  } else {
114  // Block id refers to big blocks
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];
120  }
121  }
122  if (isset($this->params['size'])) {
123  $this->data = substr($this->data, 0, $this->params['size']);
124  }
125 
126  if ($options & STREAM_USE_PATH) {
127  $openedPath = $path;
128  }
129 
130  return true;
131  }
if(!is_array($argv)) $options
$GLOBALS['ct_recipient']
$path
Definition: index.php:22

◆ stream_read()

OLE_ChainedBlockStream::stream_read (   $count)

Implements support for fread(), fgets() etc.

Parameters
intmaximum number of bytes to read
Returns
string

Definition at line 148 of file ChainedBlockStream.php.

References stream_eof().

149  {
150  if ($this->stream_eof()) {
151  return false;
152  }
153  $s = substr($this->data, $this->pos, $count);
154  $this->pos += $count;
155  return $s;
156  }
stream_eof()
Implements support for feof().
+ Here is the call graph for this function:

◆ stream_seek()

OLE_ChainedBlockStream::stream_seek (   $offset,
  $whence 
)

Implements support for fseek().

Parameters
intbyte offset
intSEEK_SET, SEEK_CUR or SEEK_END
Returns
bool

Definition at line 190 of file ChainedBlockStream.php.

191  {
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;
198  } else {
199  return false;
200  }
201  return true;
202  }

◆ stream_stat()

OLE_ChainedBlockStream::stream_stat ( )

Implements support for fstat().

Currently the only supported field is "size".

Returns
array

Definition at line 209 of file ChainedBlockStream.php.

210  {
211  return array(
212  'size' => strlen($this->data),
213  );
214  }

◆ stream_tell()

OLE_ChainedBlockStream::stream_tell ( )

Returns the position of the file pointer, i.e.

its offset into the file stream. Implements support for ftell().

Returns
int

Definition at line 179 of file ChainedBlockStream.php.

References $pos.

180  {
181  return $this->pos;
182  }

Field Documentation

◆ $data

OLE_ChainedBlockStream::$data

Definition at line 59 of file ChainedBlockStream.php.

◆ $ole

OLE_ChainedBlockStream::$ole

Definition at line 47 of file ChainedBlockStream.php.

◆ $params

OLE_ChainedBlockStream::$params

Definition at line 53 of file ChainedBlockStream.php.

◆ $pos

OLE_ChainedBlockStream::$pos

Definition at line 65 of file ChainedBlockStream.php.

Referenced by stream_tell().


The documentation for this class was generated from the following file: