JArchiveZip

Implements \JArchiveExtractable

ZIP format adapter for the JArchive class

deprecated

The ZIP compression code is partially based on code from: Eric Mueller eric@themepark.com http://www.zend.com/codex.php?id=535&single=1

Deins125 webmaster@atlant.ru http://www.zend.com/codex.php?id=470&single=1

The ZIP compression date code is partially based on code from Peter Listiak mlady@users.sourceforge.net

This class is inspired from and draws heavily in code and concept from the Compress package of The Horde Project https://www.horde.org

contributor

Chuck Hagenbuch chuck@horde.org

Michael Slusarz slusarz@horde.org

Michael Cochrane mike@graftonhall.co.nz

since

11.1

deprecated

4.0 use the Joomla\Archive\Zip class instead

package

Joomla.Platform

Methods

_addToZIPFile

Adds a "file" to the ZIP archive.

_addToZIPFile(array &$file, array &$contents, array &$ctrldir) : void
since

11.1

todo

Review and finish implementation

Arguments

$file

array

$contents

array

$ctrldir

array

_createZIPFile

Creates the ZIP file.

_createZIPFile(array &$contents, array &$ctrlDir, string $path) : boolean
since

11.1

todo

Review and finish implementation

Arguments

$contents

array

$ctrlDir

array

$path

stringThe path to store the archive.

Response

booleanTrue if successful

_getFileData

Returns the file data for a file by offsest in the ZIP archive

_getFileData(integer $key) : string
since

11.1

Arguments

$key

integerThe position of the file in the archive.

Response

stringUncompressed file data buffer.

_readZipInfo

Get the list of files/data from a ZIP archive buffer.

_readZipInfo( &$data) : boolean
KEY: Position in zipfile
VALUES: 'attr'  --  File attributes
'crc'   --  CRC checksum
'csize' --  Compressed file size
'date'  --  File modification time
'name'  --  Filename
'method'--  Compression method
'size'  --  Original file size
'type'  --  File type
since

11.1

throws

\RuntimeException

Arguments

$data

Response

booleanTrue on success

_unix2DOSTime

Converts a UNIX timestamp to a 4-byte DOS date and time format (date in high 2-bytes, time in low 2-bytes allowing magnitude comparison).

_unix2DOSTime(integer $unixtime = null) : integer
since

11.1

Arguments

$unixtime

integerThe current UNIX timestamp.

Response

integerThe current date in a 4-byte DOS format.

checkZipData

Checks to see if the data is a valid ZIP file.

checkZipData( &$data) : boolean
since

11.1

Arguments

$data

Response

booleanTrue if valid, false if invalid.

create

Create a ZIP compressed file from an array of file data.

create(string $archive, array $files) : boolean
since

11.1

todo

Finish Implementation

Arguments

$archive

stringPath to save archive.

$files

arrayArray of files to add to archive.

Response

booleanTrue if successful.

extract

Extract a ZIP compressed file to a given path

extract(string $archive, string $destination, array $options = array()) : boolean
since

11.1

throws

\RuntimeException

Arguments

$archive

stringPath to ZIP archive to extract

$destination

stringPath to extract archive into

$options

arrayExtraction options [unused]

Response

booleanTrue if successful

extractCustom

Extract a ZIP compressed file to a given path using a php based algorithm that only requires zlib support

extractCustom(string $archive, string $destination) : mixed
since

11.1

throws

\RuntimeException

Arguments

$archive

stringPath to ZIP archive to extract.

$destination

stringPath to extract archive into.

Response

mixedTrue if successful

extractNative

Extract a ZIP compressed file to a given path using native php api calls for speed

extractNative(string $archive, string $destination) : boolean
since

11.1

throws

\RuntimeException

Arguments

$archive

stringPath to ZIP archive to extract

$destination

stringPath to extract archive into

Response

booleanTrue on success

hasNativeSupport

Method to determine if the server has native zip support for faster handling

hasNativeSupport() : boolean
static
since

11.1

Response

booleanTrue if php has native ZIP support

isSupported

Tests whether this adapter can unpack files on this computer.

isSupported() : boolean
static
since

11.3

Response

booleanTrue if supported

raiseWarning

Temporary private method to isolate JError from the extract method This code should be removed when JError is removed.

raiseWarning(integer $code, string $msg) : \JException
throws

\RuntimeExceptionif JError class does not exist

Arguments

$code

integerThe application-internal error code for this error

$msg

stringThe error message, which may also be shown the user if need be.

Response

\JExceptionJException instance if JError class exists

Properties

_methods

ZIP compression methods.

Type(s)

array

_ctrlDirHeader

Beginning of central directory record.

Type(s)

string

_ctrlDirEnd

End of central directory record.

Type(s)

string

_fileHeader

Beginning of file contents.

Type(s)

string

_data

ZIP file data buffer

Type(s)

string