ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups 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().
 stream_close ()
 Implements support for fclose().
 stream_read ($count)
 Implements support for fread(), fgets() etc.
 stream_eof ()
 Implements support for feof().
 stream_tell ()
 Returns the position of the file pointer, i.e.
 stream_seek ($offset, $whence)
 Implements support for fseek().
 stream_stat ()
 Implements support for fstat().
- Public Member Functions inherited from PEAR
 PEAR ($error_class=null)
 Constructor.
 _PEAR ()
 Destructor (the emulated type of...).
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.
 registerShutdownFunc ($func, $args=array())
 Use this function to register a shutdown method for static classes.
 isError ($data, $code=null)
 Tell whether a value is a PEAR error.
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this object should be handled.
 expectError ($code= '*')
 This method is used to tell which errors you expect to get.
 popExpect ()
 This method pops one element off the expected error codes stack.
 _checkDelExpect ($error_code)
 This method checks unsets an error code if available.
 delExpect ($error_code)
 This method deletes all occurences of the specified element from the expected error codes stack.
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.
throwError ($message=null, $code=null, $userinfo=null)
 Simpler form of raiseError with fewer options.
 staticPushErrorHandling ($mode, $options=null)
 staticPopErrorHandling ()
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack.
 popErrorHandling ()
 Pop the last error handler used.
 loadExtension ($ext)
 OS independant PHP extension load.

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

OLE_ChainedBlockStream::stream_close ( )

Implements support for fclose().

Returns
string

Definition at line 137 of file ChainedBlockStream.php.

References $GLOBALS.

{
$this->ole = null;
unset($GLOBALS['_OLE_INSTANCES']);
}
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().

{
$eof = $this->pos >= strlen($this->data);
// Workaround for bug in PHP 5.0.x: http://bugs.php.net/27508
if (version_compare(PHP_VERSION, '5.0', '>=') &&
version_compare(PHP_VERSION, '5.1', '<')) {
$eof = !$eof;
}
return $eof;
}

+ Here is the caller graph for this function:

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, $path, and $pos.

{
if ($mode != 'r') {
if ($options & STREAM_REPORT_ERRORS) {
trigger_error('Only reading is supported', E_USER_WARNING);
}
return false;
}
// 25 is length of "ole-chainedblockstream://"
parse_str(substr($path, 25), $this->params);
if (!isset($this->params['oleInstanceId'],
$this->params['blockId'],
$GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']])) {
if ($options & STREAM_REPORT_ERRORS) {
trigger_error('OLE stream not found', E_USER_WARNING);
}
return false;
}
$this->ole = $GLOBALS['_OLE_INSTANCES'][$this->params['oleInstanceId']];
$blockId = $this->params['blockId'];
$this->data = '';
if (isset($this->params['size']) &&
$this->params['size'] < $this->ole->bigBlockThreshold &&
$blockId != $this->ole->root->_StartBlock) {
// Block id refers to small blocks
$rootPos = $this->ole->_getBlockOffset($this->ole->root->_StartBlock);
while ($blockId != -2) {
$pos = $rootPos + $blockId * $this->ole->bigBlockSize;
$blockId = $this->ole->sbat[$blockId];
fseek($this->ole->_file_handle, $pos);
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
}
} else {
// Block id refers to big blocks
while ($blockId != -2) {
$pos = $this->ole->_getBlockOffset($blockId);
fseek($this->ole->_file_handle, $pos);
$this->data .= fread($this->ole->_file_handle, $this->ole->bigBlockSize);
$blockId = $this->ole->bbat[$blockId];
}
}
if (isset($this->params['size'])) {
$this->data = substr($this->data, 0, $this->params['size']);
}
if ($options & STREAM_USE_PATH) {
$openedPath = $path;
}
return true;
}
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().

{
if ($this->stream_eof()) {
return false;
}
$s = substr($this->data, $this->pos, $count);
$this->pos += $count;
return $s;
}

+ Here is the call graph for this function:

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.

{
if ($whence == SEEK_SET && $offset >= 0) {
$this->pos = $offset;
} elseif ($whence == SEEK_CUR && -$offset <= $this->pos) {
$this->pos += $offset;
} elseif ($whence == SEEK_END && -$offset <= sizeof($this->data)) {
$this->pos = strlen($this->data) + $offset;
} else {
return false;
}
return true;
}
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.

{
return array(
'size' => strlen($this->data),
);
}
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.

{
return $this->pos;
}

Field Documentation

OLE_ChainedBlockStream::$data

Definition at line 59 of file ChainedBlockStream.php.

OLE_ChainedBlockStream::$ole

Definition at line 47 of file ChainedBlockStream.php.

OLE_ChainedBlockStream::$params

Definition at line 53 of file ChainedBlockStream.php.

OLE_ChainedBlockStream::$pos

Definition at line 65 of file ChainedBlockStream.php.

Referenced by stream_open(), and stream_tell().


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