Allows reading and writing of bytes to and from a file.

package Swift
subpackage ByteStream
author Chris Corbyn

 Methods

Create a new FileByteStream for $path.

__construct(string $path, string $writable) 

Parameters

$path

string

$writable

string

if true

Add a StreamFilter to this InputByteStream.

addFilter(\Swift_StreamFilter $filter, string $key) 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::addFilter()

Parameters

$key

string

Attach $is to this stream.

bind(\Swift_InputByteStream $is) 
Inherited

The stream acts as an observer, receiving all data that is written. All write() and flushBuffers() operations will be mirrored.

inherited_from \Swift_ByteStream_AbstractFilterableInputStream::bind()

Parameters

For any bytes that are currently buffered inside the stream, force them off the buffer.

commit() 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::commit()

Exceptions

\Swift_IoException

Flush the contents of the stream (empty it) and set the internal pointer to the beginning.

flushBuffers() 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::flushBuffers()

Exceptions

\Swift_IoException

Get the complete path to the file.

getPath() : string

Returns

string

Reads $length bytes from the stream into a string and moves the pointer through the stream by $length.

read(int $length) : string

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

Exceptions

\Swift_IoException

Returns

string

Remove an already present StreamFilter based on its $key.

removeFilter(string $key) 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::removeFilter()

Parameters

$key

string

Move the internal read pointer to $byteOffset in the stream.

setReadPointer(int $byteOffset) : boolean

Parameters

$byteOffset

int

Returns

boolean

Remove an already bound stream.

unbind(\Swift_InputByteStream $is) 
Inherited

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.

inherited_from \Swift_ByteStream_AbstractFilterableInputStream::unbind()

Parameters

Writes $bytes to the end of the stream.

write(string $bytes) : int
Inherited

Writing may not happen immediately if the stream chooses to buffer. If you want to write these bytes with immediate effect, call commit() after calling write().

This method returns the sequence ID of the write (i.e. 1 for first, 2 for second, etc etc).

inherited_from \Swift_ByteStream_AbstractFilterableInputStream::write()

Parameters

$bytes

string

Exceptions

\Swift_IoException

Returns

int

Just write the bytes to the file

_commit(string $bytes) 

Parameters

$bytes

string

Not used

_flush() 

Copy a readOnly Stream to ensure seekability

_copyReadStream() 

Just write the bytes to the stream

_doWrite($bytes) 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::_doWrite()

Parameters

$bytes

Run $bytes through all filters

_filter($bytes) 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::_filter()

Parameters

$bytes

Get the resource for reading

_getReadHandle() 

Check if ReadOnly Stream is seekable

_getReadStreamSeekableStatus() 

Get the resource for writing

_getWriteHandle() 

Force a reload of the resource for reading

_resetReadHandle() 

Streams in a readOnly stream ensuring copy if needed

_seekReadStreamToPosition($offset) 

Parameters

$offset

 Properties

 

$_sequence 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::$$_sequence
 

$_filters 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::$$_filters
 

$_mirrors 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::$$_mirrors
 

$_mode 
 

$_offset 
 

$_path 
 

$_quotes 
 

$_reader 
 

$_seekable 
 

$_writeBuffer 
Inherited
inherited_from \Swift_ByteStream_AbstractFilterableInputStream::$$_writeBuffer
 

$_writer