FileByteStream
extends AbstractFilterableInputStream
in package
implements
FileInterface
File byte stream class
Tags
Interfaces, Classes, Traits and Enums
- FileInterface
- File stream interface
Table of Contents
- $sequence : int
- Write sequence
- $filters : array<string|int, mixed>
- StreamFilters
- $mirrors : array<string|int, mixed>
- Bound streams
- $mode : string
- The mode this file is opened in for writing
- $offset : int
- The internal pointer offset
- $path : string
- The path to the file
- $reader : resource
- A lazy-loaded resource handle for reading the file
- $seekable : mixed
- If stream is seekable true/false, or null if not known
- $writeBuffer : string
- A buffer for writing
- $writer : resource
- A lazy-loaded resource handle for writing the file
- __construct() : mixed
- Create a new FileByteStream for $path.
- addFilter() : mixed
- Add a StreamFilter to this InputByteStream
- bind() : mixed
- Attach $is to this stream.
- commit() : mixed
- For any bytes that are currently buffered inside the stream, force them off the buffer
- flushBuffers() : mixed
- Flush the contents of the stream (empty it) and set the internal pointer to the beginning.
- getPath() : string
- Get the complete path to the file
- read() : string|bool
- Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.
- removeFilter() : mixed
- Remove an already present StreamFilter based on its $key
- setReadPointer() : bool
- Move the internal read pointer to $byteOffset in the stream
- unbind() : mixed
- Remove an already bound stream.
- write() : int
- Writes $bytes to the end of the stream
- commitBytes() : mixed
- Just write the bytes to the file
- flush() : mixed
- Not used
- copyReadStream() : mixed
- Copy a readOnly Stream to ensure seekability
- doWrite() : mixed
- Just write the bytes to the stream
- filter() : int
- Run $bytes through all filters
- getReadHandle() : resource
- Get the resource for reading
- getReadStreamSeekableStatus() : mixed
- Check if ReadOnly Stream is seekable
- getWriteHandle() : resource
- Get the resource for writing
- resetReadHandle() : mixed
- Force a reload of the resource for reading
- seekReadStreamToPosition() : mixed
- Streams in a readOnly stream ensuring copy if needed
Properties
$sequence
Write sequence
protected
int
$sequence
= 0
$filters
StreamFilters
private
array<string|int, mixed>
$filters
= []
$mirrors
Bound streams
private
array<string|int, mixed>
$mirrors
= []
$mode
The mode this file is opened in for writing
private
string
$mode
$offset
The internal pointer offset
private
int
$offset
= 0
$path
The path to the file
private
string
$path
$reader
A lazy-loaded resource handle for reading the file
private
resource
$reader
$seekable
If stream is seekable true/false, or null if not known
private
mixed
$seekable
= null
$writeBuffer
A buffer for writing
private
string
$writeBuffer
= ''
$writer
A lazy-loaded resource handle for writing the file
private
resource
$writer
Methods
__construct()
Create a new FileByteStream for $path.
public
__construct(string $path[, bool $writable = false ]) : mixed
Parameters
- $path : string
- $writable : bool = false
-
if true
Tags
Return values
mixed —addFilter()
Add a StreamFilter to this InputByteStream
public
addFilter(FilterInterface $filter, string $key) : mixed
Parameters
- $filter : FilterInterface
- $key : string
Return values
mixed —bind()
Attach $is to this stream.
public
bind(InputInterface $is) : mixed
The stream acts as an observer, receiving all data that is written. All and operations will be mirrored.
Parameters
- $is : InputInterface
Return values
mixed —commit()
For any bytes that are currently buffered inside the stream, force them off the buffer
public
commit() : mixed
Return values
mixed —flushBuffers()
Flush the contents of the stream (empty it) and set the internal pointer to the beginning.
public
flushBuffers() : mixed
Return values
mixed —getPath()
Get the complete path to the file
public
getPath() : string
Return values
string —read()
Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.
public
read(int $length) : string|bool
If less bytes exist than are requested the remaining bytes are given instead. If no bytes are remaining at all, boolean false is returned.
Parameters
- $length : int
Tags
Return values
string|bool —removeFilter()
Remove an already present StreamFilter based on its $key
public
removeFilter(string $key) : mixed
Parameters
- $key : string
Return values
mixed —setReadPointer()
Move the internal read pointer to $byteOffset in the stream
public
setReadPointer(int $byteOffset) : bool
Parameters
- $byteOffset : int
Return values
bool —unbind()
Remove an already bound stream.
public
unbind(InputInterface $is) : mixed
If $is is not bound, no errors will be raised. If the stream currently has any buffered data it will be written to $is before unbinding occurs.
Parameters
- $is : InputInterface
Return values
mixed —write()
Writes $bytes to the end of the stream
public
write(string $bytes) : int
Parameters
- $bytes : string
Return values
int —commitBytes()
Just write the bytes to the file
protected
commitBytes(string $bytes) : mixed
Parameters
- $bytes : string
Return values
mixed —flush()
Not used
protected
flush() : mixed
Return values
mixed —copyReadStream()
Copy a readOnly Stream to ensure seekability
private
copyReadStream() : mixed
Return values
mixed —doWrite()
Just write the bytes to the stream
private
doWrite(int $bytes) : mixed
Parameters
- $bytes : int
Return values
mixed —filter()
Run $bytes through all filters
private
filter(int $bytes) : int
Parameters
- $bytes : int
Return values
int —getReadHandle()
Get the resource for reading
private
getReadHandle() : resource
Tags
Return values
resource —getReadStreamSeekableStatus()
Check if ReadOnly Stream is seekable
private
getReadStreamSeekableStatus() : mixed
Return values
mixed —getWriteHandle()
Get the resource for writing
private
getWriteHandle() : resource
Tags
Return values
resource —resetReadHandle()
Force a reload of the resource for reading
private
resetReadHandle() : mixed
Return values
mixed —seekReadStreamToPosition()
Streams in a readOnly stream ensuring copy if needed
private
seekReadStreamToPosition(int $offset) : mixed
Parameters
- $offset : int