Zip
Implements \Joomla\Archive\ExtractableInterfaceZIP format adapter for the Archive package
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 http://www.horde.org
contributor |
Chuck Hagenbuch chuck@horde.org Michael Slusarz slusarz@horde.org Michael Cochrane mike@graftonhall.co.nz |
---|---|
since |
1.0 |
Methods
__construct
Create a new Archive object.
__construct(array|\ArrayAccess $options = array())
since |
1.0 |
---|---|
throws |
|
Arguments
- $options
array|\ArrayAccess
An array of options or an object that implements \ArrayAccess
addToZipFile
Adds a "file" to the ZIP archive.
addToZipFile(array &$file, array &$contents, array &$ctrldir) : void
since |
1.0 |
---|---|
todo |
Review and finish implementation |
Arguments
- $file
array
- $contents
array
- $ctrldir
array
checkZipData
Checks to see if the data is a valid ZIP file.
checkZipData( &$data) : boolean
since |
1.0 |
---|
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.0 |
---|---|
todo |
Finish Implementation |
Arguments
- $archive
string
Path to save archive.- $files
array
Array of files to add to archive.
Response
boolean
True if successful.
createZipFile
Creates the ZIP file.
createZipFile(array &$contents, array &$ctrlDir, string $path) : boolean
Official ZIP file format: http://www.pkware.com/appnote.txt
since |
1.0 |
---|---|
todo |
Review and finish implementation |
Arguments
- $contents
array
- $ctrlDir
array
- $path
string
The path to store the archive.
Response
boolean
True if successful
extract
Extract a ZIP compressed file to a given path
extract(string $archive, string $destination) : boolean
since |
1.0 |
---|---|
throws |
|
Arguments
- $archive
string
Path to ZIP archive to extract- $destination
string
Path to extract archive into
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) : boolean
since |
1.0 |
---|---|
throws |
|
Arguments
- $archive
string
Path to ZIP archive to extract.- $destination
string
Path to extract archive into.
Response
boolean
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 |
1.0 |
---|---|
throws |
|
Arguments
- $archive
string
Path to ZIP archive to extract- $destination
string
Path to extract archive into
Response
boolean
True on success
getFileData
Returns the file data for a file by offsest in the ZIP archive
getFileData(integer $key) : string
since |
1.0 |
---|
Arguments
- $key
integer
The position of the file in the archive.
Response
string
Uncompressed file data buffer.
hasNativeSupport
Method to determine if the server has native zip support for faster handling
hasNativeSupport() : boolean
since |
1.0 |
---|
Response
boolean
True if php has native ZIP support
isSupported
Tests whether this adapter can unpack files on this computer.
isSupported() : boolean
since |
1.0 |
---|
Response
boolean
True if supported
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 |
1.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.0 |
---|
Arguments
- $unixtime
integer
The current UNIX timestamp.
Response
integer
The current date in a 4-byte DOS format.
Properties
methods
ZIP compression methods.
since |
1.0 |
---|
Type(s)
array
ctrlDirHeader
Beginning of central directory record.
since |
1.0 |
---|
Type(s)
string
ctrlDirEnd
End of central directory record.
since |
1.0 |
---|
Type(s)
string
fileHeader
Beginning of file contents.
since |
1.0 |
---|
Type(s)
string
data
ZIP file data buffer
since |
1.0 |
---|
Type(s)
string
metadata
ZIP file metadata array
since |
1.0 |
---|
Type(s)
array
options
Holds the options array.
since |
1.0 |
---|
Type(s)
array|\ArrayAccess