setasign\SetaPDF2\Core\Reader
MaxFileReader Class for a file reader respecting the maximum allowed open file handles/descriptors.
File: /SetaPDF v2/Core/Reader/MaxFileReader.php
Old class name (alias):
\SetaPDF_Core_Reader_MaxFile
Class hierarchy
Implements
Summary
Methods
- __construct()
- __destruct()
- __sleep()
- __wakeup()
- _closeFile()
- _openFile()
- _setFilename()
- _setStream()
- addOffset()
- cleanUp()
- copyTo()
- ensure()
- ensureContent()
- getBuffer()
- getByte()
- getFilename()
- getHandler()
- getLength()
- getOffset()
- getPos()
- getStream()
- getTotalLength()
- increaseLength()
- isSleeping()
- readByte()
- readBytes()
- readLine()
- reset()
- setHandler()
- setOffset()
- sleep()
- wakeUp()
Properties
$_stream
The stream resource
$_totalLength
The total length
Methods
__construct()
The constructor.
Parameters
- $filename : string
- $handler : ?\SetaPDF_Core_Reader_MaxFileHandler
The handler to which this instance should be bound and notify when opening closing file handles.
Exceptions
Throws Exception
__sleep()
__wakeup()
_setFilename()
_setStream()
Set the stream.
Parameters
- $stream : resource
Exceptions
Throws \InvalidArgumentException
Throws Exception
addOffset()
copyTo()
Copies the complete content to a writer instance.
Parameters
- $writer : \SetaPDF_Core_WriteInterface
Exceptions
Throws Exception
ensure()
Ensures bytes in the buffer with a specific length and location in the file.
Parameters
- $pos : int
- $length : int
See
ensureContent()
Make sure that there is at least one character beyond the current offset in the buffer.
getByte()
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 : int
getTotalLength()
increaseLength()
readByte()
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 : int
readBytes()
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 : int
- $pos : int
readLine()
reset()
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
Start position of the new buffer
- $length : int
Length of the new buffer. Mustn't be negative
Exceptions
Throws Exception
setHandler()
setOffset()
sleep()
Set the reader into sleep-state.
In this implementation the file handles will be closed to avoid reaching the limit of open file handles.