PHP Класс ParagonIE\Halite\Stream\ReadOnlyFile

Наследование: implements ParagonIE\Halite\Contract\StreamInterface
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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!

Описание методов

__construct() публичный Метод

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

__destruct() публичный Метод

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

close() публичный Метод

Close the file handle.
public close ( )

getHash() публичный Метод

Calculate a BLAKE2b hash of a file
public getHash ( ) : string
Результат string

getPos() публичный Метод

Where are we in the buffer?
public getPos ( ) : integer
Результат integer

getSize() публичный Метод

How big is this buffer?
public getSize ( ) : integer
Результат integer

readBytes() публичный Метод

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!
Результат string

remainingBytes() публичный Метод

Get number of bytes remaining
public remainingBytes ( ) : integer
Результат integer

reset() публичный Метод

Set the current cursor position to the desired location
public reset ( integer $position ) : boolean
$position integer
Результат boolean

toctouTest() публичный Метод

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
Результат void

writeBytes() публичный Метод

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)
Результат integer