SetaPDF_Core_Reader_File Class for a file reader

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

Class hierarchy

Implements

Summary

Properties

$_buffer

The current buffer

$_filename

protected string SetaPDF_Core_Reader_File::$_filename = ''

The filename

$_length

The length of the buffer

$_offset

The offset to the current position

$_pos

The current file position

$_stream

The stream resource

$_totalLength

The total length


Methods

__construct()

public SetaPDF_Core_Reader_File::__construct (
string $filename
)

The constructor.

Parameters
$filename : string
 
Exceptions

Throws SetaPDF_Core_Reader_Exception

__destruct()

public SetaPDF_Core_Reader_Stream::__destruct (
void
): void

The destruct method.

See

__sleep()

public SetaPDF_Core_Reader_File::__sleep (
void
): array

Implementation of the __sleep() method.

Exceptions

Throws BadMethodCallException

_closeFile()

protected SetaPDF_Core_Reader_File::_closeFile (
void
): void

Closes the file handle.

Mainly used for testing purposes.

See

_openFile()

protected SetaPDF_Core_Reader_File::_openFile (
string $filename
): resource|false

Opens the file.

Mainly used for testing purposes.

Parameters
$filename : string
 

_setFilename()

protected SetaPDF_Core_Reader_File::_setFilename (
string $filename
): void

Set the filename.

Parameters
$filename : string
 
Exceptions

Throws SetaPDF_Core_Reader_Exception

_setStream()

protected SetaPDF_Core_Reader_Stream::_setStream (
resource $stream
): void

Set the stream.

Parameters
$stream : resource
 
Exceptions

Throws InvalidArgumentException

Throws SetaPDF_Core_Reader_Exception

addOffset()

public SetaPDF_Core_Reader_AbstractReader::addOffset (
integer $offset
): void

Add an offset to the current offset.

Parameters
$offset : integer
 
Exceptions

Throws SetaPDF_Core_Reader_Exception

cleanUp()

copyTo()

Copies the complete content to a writer instance.

Parameters
$writer : SetaPDF_Core_WriteInterface
 

ensure()

public SetaPDF_Core_Reader_AbstractReader::ensure (
int $pos, int $length
): void

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.

getBuffer()

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

Returns the current buffer.

Parameters
$atOffset : boolean
 

getByte()

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

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 SetaPDF_Core_Reader_File::getFilename (
void
): string

Returns the filename.

getLength()

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

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 SetaPDF_Core_Reader_Stream::getStream (
void
): resource

Returns the stream.

getTotalLength()

Gets the total available length.

Exceptions

Throws SetaPDF_Core_Reader_Exception

increaseLength()

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

Forcefully read more data into the buffer.

Parameters
$minLength : int
 
Exceptions

Throws SetaPDF_Core_Reader_Exception

readByte()

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

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 SetaPDF_Core_Reader_AbstractReader::readBytes (
integer $length [, integer $pos = null ]
): string|boolean

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 SetaPDF_Core_Reader_AbstractReader::readLine (
[ integer $length = 1024 ]
): string|false

Read a line from the current position.

Parameters
$length : integer
 
Exceptions

Throws SetaPDF_Core_Reader_Exception

reset()

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

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

Exceptions

Throws SetaPDF_Core_Reader_Exception

setOffset()

public SetaPDF_Core_Reader_AbstractReader::setOffset (
int $offset
): void

Set the offset position.

Parameters
$offset : int
 
Exceptions

Throws SetaPDF_Core_Reader_Exception