Bencodex

StreamReader
in package
implements Reader

A stream reader, which usually refers to a file.

Interfaces, Classes, Traits and Enums

Reader
An interface to read a byte string (which can be quite long) in separated multiple chunks.

Table of Contents

__construct()  : void
Creates a new {@see StreamReader} instance with the given handle.
read()  : string
Reads a chunk of bytes.
seek()  : void
Fast-forwards or rewinds the offset.
tell()  : int
Gets the current offset in the buffer.

Methods

__construct()

Creates a new {@see StreamReader} instance with the given handle.

public __construct(resource $handle) : void
Parameters
$handle : resource

The pointer resource which refers a readable stream, usually a file.

Tags
throws
TypeError

Thrown when the given handle is not a resource.

Return values
void

read()

Reads a chunk of bytes.

public read(mixed $size) : string
Parameters
$size : mixed

The size of bytes to request. Zero or negative integers reads nothing and an empty string is returned.

Tags
inheritDoc
Return values
string

The read bytes. It may be shorter than the requested size if there is not enough bytes to read.

seek()

Fast-forwards or rewinds the offset.

public seek(mixed $offset) : void
Parameters
$offset : mixed

The number of bytes to move the offset pointer. Negative integers rewind and positive integers fast-forward. (Zero is no-op.) If the destination is less than zero or greater than the entire length, the offset is set to zero or the end of the entire buffer.

Tags
inheritDoc
Return values
void

tell()

Gets the current offset in the buffer.

public tell() : int
Tags
inheritDoc
Return values
int

The current offset.

Search results