PHP Class ParagonIE\Halite\Stream\ReadOnlyFile

Inheritance: implements ParagonIE\Halite\Contract\StreamInterface
Datei anzeigen Open project: paragonie/halite Class Usage Examples

Public Methods

Method Description
__construct ( $file, Key $key = null ) ReadOnlyFile constructor
__destruct ( ) Make sure we invoke $this->close()
close ( ) Close the file handle.
getHash ( ) : string Calculate a BLAKE2b hash of a file
getPos ( ) : integer Where are we in the buffer?
getSize ( ) : integer How big is this buffer?
readBytes ( integer $num, boolean $skipTests = false ) : string Read from a stream; prevent partial reads (also uses run-time testing to prevent partial reads -- you can turn this off if you need performance and aren't concerned about race condition attacks, but this isn't a decision to make lightly!)
remainingBytes ( ) : integer Get number of bytes remaining
reset ( integer $position ) : boolean Set the current cursor position to the desired location
toctouTest ( ) : void Run-time test to prevent TOCTOU attacks (race conditions) through verifying that the hash matches and the current cursor position/file size matches their values when the file was first opened.
writeBytes ( string $buf, integer $num = null ) : integer This is a meaningless operation for a Read-Only File!

Method Details

__construct() public method

ReadOnlyFile constructor
public __construct ( $file, Key $key = null )
$file
$key ParagonIE\Halite\Key

__destruct() public method

Make sure we invoke $this->close()
public __destruct ( )

close() public method

Close the file handle.
public close ( )

getHash() public method

Calculate a BLAKE2b hash of a file
public getHash ( ) : string
return string

getPos() public method

Where are we in the buffer?
public getPos ( ) : integer
return integer

getSize() public method

How big is this buffer?
public getSize ( ) : integer
return integer

readBytes() public method

Read from a stream; prevent partial reads (also uses run-time testing to prevent partial reads -- you can turn this off if you need performance and aren't concerned about race condition attacks, but this isn't a decision to make lightly!)
public readBytes ( integer $num, boolean $skipTests = false ) : string
$num integer
$skipTests boolean Only set this to TRUE if you're absolutely sure that you don't want to defend against TOCTOU / race condition attacks on the filesystem!
return string

remainingBytes() public method

Get number of bytes remaining
public remainingBytes ( ) : integer
return integer

reset() public method

Set the current cursor position to the desired location
public reset ( integer $position ) : boolean
$position integer
return boolean

toctouTest() public method

Run-time test to prevent TOCTOU attacks (race conditions) through verifying that the hash matches and the current cursor position/file size matches their values when the file was first opened.
public toctouTest ( ) : void
return void

writeBytes() public method

This is a meaningless operation for a Read-Only File!
public writeBytes ( string $buf, integer $num = null ) : integer
$buf string
$num integer (number of bytes)
return integer