SetaPDF_Core_Reader_MaxFile Class for a file reader respecting the maximum allowed open file handles/descriptors.

File: /SetaPDF/Core/Reader/MaxFile.php

Class hierarchy

Implements

Summary

Properties

$_buffer

protected string SetaPDF_Core_Reader_MaxFile::$_buffer = ''

The current buffer

$_filename

The filename

$_length

The length of the buffer

$_offset

The offset to the current position

$_pos

The current file position

$_sleepPosition

The position of the point before sleep() was called

$_sleeping

protected boolean SetaPDF_Core_Reader_MaxFile::$_sleeping = true

Defines if the reader is sleeping

$_stream

The stream resource

$_totalLength

The total length


Methods

__construct()

public SetaPDF_Core_Reader_MaxFile::__construct ( string $filename [, SetaPDF_Core_Reader_MaxFileHandler|null $handler = null ] )

The constructor.

Parameters
$filename : string
 
$handler : SetaPDF_Core_Reader_MaxFileHandler|null

The handler to which this instance should be bound and notify when opening closing file handles.

Exceptions

Throws Exception

__destruct()

The destruct method.

See

__sleep()

public array SetaPDF_Core_Reader_MaxFile::__sleep ( void )

Implementation of the __sleep() method.

Exceptions

Throws BadMethodCallException

_closeFile()

protected void SetaPDF_Core_Reader_MaxFile::_closeFile ( void )

Closes the file handle.

_openFile()

protected resource SetaPDF_Core_Reader_MaxFile::_openFile ( string $filename )

Opens the file.

Parameters
$filename : string
 

_setFilename()

protected void SetaPDF_Core_Reader_File::_setFilename ( string $filename )

Set the filename.

Parameters
$filename : string
 
Exceptions

Throws SetaPDF_Core_Reader_Exception

_setStream()

protected void SetaPDF_Core_Reader_Stream::_setStream ( resource $stream )

Set the stream.

Parameters
$stream : resource
 
Exceptions

Throws InvalidArgumentException

addOffset()

public void SetaPDF_Core_Reader_AbstractReader::addOffset ( integer $offset )

Add an offset to the current offset.

Parameters
$offset : integer
 

cleanUp()

public void SetaPDF_Core_Reader_MaxFile::cleanUp ( void )

Release memory/cylced references.

copyTo()

Copies the complete content to a writer instance.

Parameters
$writer : SetaPDF_Core_WriteInterface
 

ensureContent()

Make sure that there is at least one character beyond the current offset in the buffer.

getBuffer()

public string SetaPDF_Core_Reader_AbstractReader::getBuffer ( [ boolean $atOffset = true ] )

Returns the current buffer.

Parameters
$atOffset : boolean
 

getByte()

public string|boolean SetaPDF_Core_Reader_AbstractReader::getByte ( [ integer $pos = null ] )

Gets a byte at a specific position.

If the position is invalid the method will return false.

If non position is set $this->_offset will used.

Parameters
$pos : integer
 

getFilename()

public string SetaPDF_Core_Reader_File::getFilename ( void )

Returns the filename.

getHandler()

Returns the handler instance.

Parameters
$check : boolean
 

getLength()

public int SetaPDF_Core_Reader_AbstractReader::getLength ( [ boolean $atOffset = false ] )

Returns the byte length of the buffer.

Parameters
$atOffset : boolean
 

getOffset()

Returns the current offset of the current position.

getPos()

Get the current position of the pointer.

getStream()

public resource SetaPDF_Core_Reader_Stream::getStream ( void )

Returns the stream.

getTotalLength()

Gets the total available length.

increaseLength()

public boolean SetaPDF_Core_Reader_MaxFile::increaseLength ( [ int $minLength = 100 ] )

Forcefully read more data into the buffer.

Parameters
$minLength : int
 

isSleeping()

public boolean SetaPDF_Core_Reader_MaxFile::isSleeping ( void )

Checks if the reader is sleeping.

readByte()

public string|boolean SetaPDF_Core_Reader_AbstractReader::readByte ( [ integer $pos = null ] )

Returns a byte at a specific position, returns it and set the offset to the next byte position.

If the position is invalid the method will return false.

If non position is set $this->_offset will used.

Parameters
$pos : integer
 

readBytes()

public string SetaPDF_Core_Reader_AbstractReader::readBytes ( integer $length [, integer $pos = null ] )

Get a specific byte count from the current or at a specific offset position and set the internal pointer to the next byte.

If the position is invalid the method will return false.

If non position is set $this->_offset will used.

Parameters
$length : integer
 
$pos : integer
 

readLine()

public string SetaPDF_Core_Reader_AbstractReader::readLine ( [ integer $length = 1024 ] )

Read a line from the current position.

Parameters
$length : integer
 

reset()

public void SetaPDF_Core_Reader_MaxFile::reset ( [ int|null $pos = 0 [, int $length = 200 ]] )

Resets the buffer to a specific position and reread the buffer with the given length.

If the $pos is negative the start buffer position will be the $pos'th position from the end of the file.

If the $pos is negative and the absolute value is bigger then the totalLength of the file $pos will set to zero.

Parameters
$pos : int|null

Start position of the new buffer

$length : int

Length of the new buffer. Mustn't be negative

setHandler()

Set a handler.

Parameters
$handler : SetaPDF_Core_Reader_MaxFileHandler|null
 

setOffset()

public void SetaPDF_Core_Reader_AbstractReader::setOffset ( int $offset )

Set the offset position.

Parameters
$offset : int
 
Exceptions

Throws SetaPDF_Core_Reader_Exception

sleep()

public void SetaPDF_Core_Reader_MaxFile::sleep ( void )

Set the reader into sleep-state.

In this implementation the file handles will be closed to avoid reaching the limit of open file handles.

See

wakeUp()

public boolean SetaPDF_Core_Reader_MaxFile::wakeUp ( void )

Wake up the reader if it is in sleep-state.

Re-open the file handle.

Exceptions

Throws SetaPDF_Core_Reader_Exception

See