\PhpZip\IO\StreamZipEntryStreamWrapper

The class provides stream reuse functionality.

Stream will not be closed at {@see \PhpZip\IO\Stream\fclose}.

Summary

Methods
Properties
Constants
register()
unregister()
wrap()
stream_open()
stream_read()
stream_seek()
stream_tell()
stream_eof()
stream_stat()
stream_flush()
stream_truncate()
stream_write()
stream_cast()
stream_close()
$context
PROTOCOL
No protected methods found
No protected properties found
N/A
No private methods found
$fp
N/A

Constants

PROTOCOL

PROTOCOL = 'zipentry' : string

Properties

$context

$context : resource

Type

resource

Methods

register()

register() : bool

Returns

bool —

unregister()

unregister() : mixed

Returns

mixed —

wrap()

wrap(\PhpZip\Model\ZipEntry  $entry) : resource

Parameters

\PhpZip\Model\ZipEntry $entry

Returns

resource —

stream_open()

stream_open(string  $path, string  $mode, int  $options, string  $opened_path) : bool

Opens file or URL.

This method is called immediately after the wrapper is initialized (f.e. by {@see \PhpZip\IO\Stream\fopen()} and {@see \PhpZip\IO\Stream\file_get_contents()}).

Parameters

string $path

specifies the URL that was passed to the original function

string $mode

the mode used to open the file, as detailed for {@see \PhpZip\IO\Stream\fopen()}

int $options

Holds additional flags set by the streams API. It can hold one or more of the following values OR'd together.

string $opened_path

if the path is opened successfully, and STREAM_USE_PATH is set in options, opened_path should be set to the full path of the file/resource that was actually opened

Throws

\PhpZip\Exception\ZipException

Returns

bool —

stream_read()

stream_read(int  $count) : false|string

Read from stream.

This method is called in response to {@see \PhpZip\IO\Stream\fread()} and {@see \PhpZip\IO\Stream\fgets()}.

Note: Remember to update the read/write position of the stream (by the number of bytes that were successfully read).

Parameters

int $count

how many bytes of data from the current position should be returned

Returns

false|string —

If there are less than count bytes available, return as many as are available. If no more data is available, return either FALSE or an empty string.

stream_seek()

stream_seek(int  $offset, int  $whence = SEEK_SET) : bool

Seeks to specific location in a stream.

This method is called in response to {@see \PhpZip\IO\Stream\fseek()}. The read/write position of the stream should be updated according to the offset and whence.

Parameters

int $offset

the stream offset to seek to

int $whence

Possible values: {@see \SEEK_SET} - Set position equal to offset bytes. {@see \SEEK_CUR} - Set position to current location plus offset. {@see \SEEK_END} - Set position to end-of-file plus offset.

Returns

bool —

return TRUE if the position was updated, FALSE otherwise

stream_tell()

stream_tell() : int

Retrieve the current position of a stream.

This method is called in response to {@see \PhpZip\IO\Stream\fseek()} to determine the current position.

Returns

int —

should return the current position of the stream

stream_eof()

stream_eof() : bool

Tests for end-of-file on a file pointer.

This method is called in response to {@see \PhpZip\IO\Stream\feof()}.

Returns

bool —

should return TRUE if the read/write position is at the end of the stream and if no more data is available to be read, or FALSE otherwise

stream_stat()

stream_stat() : array

Retrieve information about a file resource.

This method is called in response to {@see \PhpZip\IO\Stream\fstat()}.

Returns

array —

stream_flush()

stream_flush() : bool

Flushes the output.

This method is called in response to {@see \PhpZip\IO\Stream\fflush()} and when the stream is being closed while any unflushed data has been written to it before. If you have cached data in your stream but not yet stored it into the underlying storage, you should do so now.

Returns

bool —

should return TRUE if the cached data was successfully stored (or if there was no data to store), or FALSE if the data could not be stored

stream_truncate()

stream_truncate(int  $new_size) : bool

Truncate stream.

Will respond to truncation, e.g., through {@see \PhpZip\IO\Stream\ftruncate()}.

Parameters

int $new_size

the new size

Returns

bool —

returns TRUE on success or FALSE on failure

stream_write()

stream_write(string  $data) : int

Write to stream.

This method is called in response to {@see fwrite().}

Note: Remember to update the current position of the stream by number of bytes that were successfully written.

Parameters

string $data

should be stored into the underlying stream

Returns

int —

should return the number of bytes that were successfully stored, or 0 if none could be stored

stream_cast()

stream_cast(int  $cast_as) : resource

Retrieve the underlaying resource.

This method is called in response to {@see \PhpZip\IO\Stream\stream_select()}.

Parameters

int $cast_as

can be {@see \PhpZip\IO\Stream\STREAM_CAST_FOR_SELECT} when {@see \PhpZip\IO\Stream\stream_select()} is callingstream_cast() or {@see \PhpZip\IO\Stream\STREAM_CAST_AS_STREAM} when stream_cast() is called for other uses

Returns

resource —

stream_close()

stream_close() : mixed

Close a resource.

This method is called in response to {@see \PhpZip\IO\Stream\fclose()}. All resources that were locked, or allocated, by the wrapper should be released.

Returns

mixed —