Class JArchiveZip

Description

ZIP format adapter for the JArchive class

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>

  • since: 11.1

Located in /libraries/joomla/filesystem/archive/zip.php (line 36)

JObject
   |
   --JArchiveZip
Variable Summary
string $_ctrlDirEnd
string $_data
string $_fileHeader
array $_metadata
array $_methods
Method Summary
static boolean hasNativeSupport ()
static boolean isSupported ()
boolean checkZipData (string &$data)
boolean create (string $archive, array $files, [array $options = array()])
boolean extract (string $archive, string $destination, [array $options = array()])
void _addToZIPFile (array &$file, array &$contents, array &$ctrldir)
boolean _createZIPFile (array &$contents, array &$ctrlDir, string $path)
boolean _extract (string $archive, string $destination, array $options)
boolean _extractNative (string $archive, string $destination, array $options)
string _getFileData (integer $key)
boolean _readZipInfo (string &$data)
integer _unix2DOSTime ([integer $unixtime = null])
Variables
string $_ctrlDirEnd = "\x50\x4b\x05\x06\x00\x00\x00\x00" (line 61)

End of central directory record.

  • since: 11.1
  • access: private
string $_ctrlDirHeader = "\x50\x4b\x01\x02" (line 53)

Beginning of central directory record.

  • since: 11.1
  • access: private
string $_data = null (line 77)

ZIP file data buffer

  • since: 11.1
  • access: private
string $_fileHeader = "\x50\x4b\x03\x04" (line 69)

Beginning of file contents.

  • since: 11.1
  • access: private
array $_metadata = null (line 85)

ZIP file metadata array

  • since: 11.1
  • access: private
array $_methods = array(0x0 => 'None', 0x1 => 'Shrunk', 0x2 => 'Super Fast', 0x3 => 'Fast', 0x4 => 'Normal', 0x5 => 'Maximum', 0x6 => 'Imploded',
0x8 => 'Deflated')
(line 44)

ZIP compression methods.

  • since: 11.1
  • access: private

Inherited Variables

Inherited from JObject

JObject::$_errors
Methods
static method hasNativeSupport (line 163)

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

  • return: True if php has native ZIP support
  • since: 11.1
  • access: public
static boolean hasNativeSupport ()
static method isSupported (line 151)

Tests whether this adapter can unpack files on this computer.

  • return: True if supported
  • since: 11.3
  • access: public
static boolean isSupported ()
checkZipData (line 177)

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

  • return: True if valid, false if invalid.
  • since: 11.1
  • access: public
boolean checkZipData (string &$data)
  • string &$data: ZIP archive data buffer.
create (line 100)

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

  • return: True if successful.
  • todo: Finish Implementation
  • since: 11.1
  • access: public
boolean create (string $archive, array $files, [array $options = array()])
  • string $archive: Path to save archive.
  • array $files: Array of files to add to archive.
  • array $options: Compression options (unused).
extract (line 125)

Extract a ZIP compressed file to a given path

  • return: True if successful
  • since: 11.1
  • access: public
boolean extract (string $archive, string $destination, [array $options = array()])
  • string $archive: Path to ZIP archive to extract
  • string $destination: Path to extract archive into
  • array $options: Extraction options [unused]
_addToZIPFile (line 527)

Adds a "file" to the ZIP archive.

  • todo: Review and finish implementation
  • since: 11.1
  • access: private
void _addToZIPFile (array &$file, array &$contents, array &$ctrldir)
  • array &$file: File data array to add
  • array &$contents: An array of existing zipped files.
  • array &$ctrldir: An array of central directory information.
_createZIPFile (line 637)

Creates the ZIP file.

Official ZIP file format: http://www.pkware.com/appnote.txt

  • return: True if successful
  • todo: Review and finish implementation
  • since: 11.1
  • access: private
boolean _createZIPFile (array &$contents, array &$ctrlDir, string $path)
  • array &$contents: An array of existing zipped files.
  • array &$ctrlDir: An array of central directory information.
  • string $path: The path to store the archive.
_extract (line 200)

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

  • return: True if successful
  • since: 11.1
  • access: private
boolean _extract (string $archive, string $destination, array $options)
  • string $archive: Path to ZIP archive to extract.
  • string $destination: Path to extract archive into.
  • array $options: Extraction options [unused].
_extractNative (line 267)

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

  • return: True if successful
  • since: 11.1
  • access: private
boolean _extractNative (string $archive, string $destination, array $options)
  • string $archive: Path to ZIP archive to extract
  • string $destination: Path to extract archive into
  • array $options: Extraction options [unused]
_getFileData (line 449)

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

  • return: Uncompressed file data buffer.
  • since: 11.1
  • access: private
string _getFileData (integer $key)
  • integer $key: The position of the file in the archive.
_readZipInfo (line 338)

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

 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

  • return: True on success.
  • since: 11.1
  • access: private
boolean _readZipInfo (string &$data)
  • string &$data: The ZIP archive buffer.
_unix2DOSTime (line 496)

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).

  • return: The current date in a 4-byte DOS format.
  • since: 11.1
  • access: private
integer _unix2DOSTime ([integer $unixtime = null])
  • integer $unixtime: The current UNIX timestamp.

Inherited Methods

Inherited From JObject

JObject::__construct()
JObject::def()
JObject::get()
JObject::getError()
JObject::getErrors()
JObject::getProperties()
JObject::set()
JObject::setError()
JObject::setProperties()
JObject::toString()
JObject::__toString()

Documentation generated on Mon, 25 Jun 2012 14:01:40 -0500 by phpDocumentor 1.4.4