PHP Class ParagonIE\Halite\Stream\ReadOnlyFile

Inheritance: implements ParagonIE\Halite\Contract\StreamInterface
Afficher le fichier Open project: paragonie/halite Class Usage Examples

Méthodes publiques

Méthode 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 méthode

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

__destruct() public méthode

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

close() public méthode

Close the file handle.
public close ( )

getHash() public méthode

Calculate a BLAKE2b hash of a file
public getHash ( ) : string
Résultat string

getPos() public méthode

Where are we in the buffer?
public getPos ( ) : integer
Résultat integer

getSize() public méthode

How big is this buffer?
public getSize ( ) : integer
Résultat integer

readBytes() public méthode

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!
Résultat string

remainingBytes() public méthode

Get number of bytes remaining
public remainingBytes ( ) : integer
Résultat integer

reset() public méthode

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

toctouTest() public méthode

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
Résultat void

writeBytes() public méthode

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)
Résultat integer