JArchiveZip
Implements \JArchiveExtractableZIP format adapter for the JArchive class
The ZIP compression code is partially based on code from: Eric Mueller [email protected] http://www.zend.com/codex.php?id=535&single=1
Deins125 [email protected] http://www.zend.com/codex.php?id=470&single=1
The ZIP compression date code is partially based on code from Peter Listiak [email protected]
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 [email protected] Michael Slusarz [email protected] Michael Cochrane [email protected] |
---|---|
since |
1.5 |
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 |
1.5 |
---|---|
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
Official ZIP file format: https://support.pkware.com/display/PKZIP/APPNOTE
since |
1.5 |
---|---|
todo |
Review and finish implementation |
Arguments
- $contents
array
- $ctrlDir
array
- $path
string
The path to store the archive.
Response
boolean
True if successful
_getFileData
Returns the file data for a file by offset in the ZIP archive
_getFileData(integer $key) : string
since |
1.5 |
---|
Arguments
- $key
integer
The position of the file in the archive.
Response
string
Uncompressed 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 |
2.5.0 |
---|---|
throws |
|
Arguments
- $data
Response
boolean
True 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 |
1.5 |
---|
Arguments
- $unixtime
integer
The current UNIX timestamp.
Response
integer
The current date in a 4-byte DOS format.
checkZipData
Checks to see if the data is a valid ZIP file.
checkZipData( &$data) : boolean
since |
1.5 |
---|
Arguments
- $data
Response
boolean
True if valid, false if invalid.
create
Create a ZIP compressed file from an array of file data.
create(string $archive, array $files) : boolean
since |
1.5 |
---|---|
todo |
Finish Implementation |
Arguments
- $archive
string
Path to save archive.- $files
array
Array of files to add to archive.
Response
boolean
True if successful.
extract
Extract a ZIP compressed file to a given path
extract(string $archive, string $destination, array $options = array()) : boolean
since |
1.5 |
---|---|
throws |
|
Arguments
- $archive
string
Path to ZIP archive to extract- $destination
string
Path to extract archive into- $options
array
Extraction options [unused]
Response
boolean
True 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 |
3.0 |
---|---|
throws |
|
Arguments
- $archive
string
Path to ZIP archive to extract.- $destination
string
Path to extract archive into.
Response
mixed
True 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 |
3.0 |
---|---|
throws |
|
Arguments
- $archive
string
Path to ZIP archive to extract- $destination
string
Path to extract archive into
Response
boolean
True on success
hasNativeSupport
Method to determine if the server has native zip support for faster handling
hasNativeSupport() : boolean
since |
1.5 |
---|
Response
boolean
True if php has native ZIP support
isSupported
Tests whether this adapter can unpack files on this computer.
isSupported() : boolean
since |
2.5.0 |
---|
Response
boolean
True 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
since |
3.6.0 |
---|---|
throws |
|
Arguments
- $code
integer
The application-internal error code for this error- $msg
string
The error message, which may also be shown the user if need be.
Response
\JException
JException instance if JError class exists
Properties
_methods
ZIP compression methods.
since |
1.5 |
---|
Type(s)
array
_ctrlDirHeader
Beginning of central directory record.
since |
1.5 |
---|
Type(s)
string
_ctrlDirEnd
End of central directory record.
since |
1.5 |
---|
Type(s)
string
_fileHeader
Beginning of file contents.
since |
1.5 |
---|
Type(s)
string
_data
ZIP file data buffer
since |
1.5 |
---|
Type(s)
string
_metadata
ZIP file metadata array
since |
1.5 |
---|
Type(s)
array