class ArchiverZip

  1. cis7 modules/system/ ArchiverZip
  2. cle7 modules/system/ ArchiverZip
  3. elmsmedia7 modules/system/ ArchiverZip
  4. icor7 modules/system/ ArchiverZip
  5. meedjum_blog7 modules/system/ ArchiverZip
  6. mooc7 modules/system/ ArchiverZip

Archiver for .zip files.



Expanded class hierarchy of ArchiverZip


Contains filters are case sensitive
Namesort descending Modifiers Type Description
ArchiverZip::$zip protected property The underlying ZipArchive instance that does the heavy lifting.
ArchiverZip::add public function Adds the specified file or directory to the archive. Overrides ArchiverInterface::add
ArchiverZip::extract public function Extracts multiple files in the archive to the specified path. Overrides ArchiverInterface::extract
ArchiverZip::getArchive public function Retrieve the zip engine itself.
ArchiverZip::listContents public function Lists all files in the archive. Overrides ArchiverInterface::listContents
ArchiverZip::remove public function Removes the specified file from the archive. Overrides ArchiverInterface::remove
ArchiverZip::__construct public function Constructs a new archiver instance. Overrides ArchiverInterface::__construct


modules/system/, line 78
Archiver implementations provided by the system module.

View source
class ArchiverZip implements ArchiverInterface {

   * The underlying ZipArchive instance that does the heavy lifting.
   * @var ZipArchive
  protected $zip;

  public function __construct($file_path) {
    $this->zip = new ZipArchive();
    if ($this->zip->open($file_path) !== TRUE) {
      // @todo: This should be an interface-specific exception some day.
      throw new Exception(t('Cannot open %file_path', array('%file_path' => $file_path)));

  public function add($file_path) {

    return $this;

  public function remove($file_path) {

    return $this;

  public function extract($path, Array $files = array()) {
    if ($files) {
      $this->zip->extractTo($path, $files);
    else {

    return $this;

  public function listContents() {
    $files = array();
    for ($i = 0; $i < $this->zip->numFiles; $i++) {
      $files[] = $this->zip->getNameIndex($i);
    return $files;

   * Retrieve the zip engine itself.
   * In some cases it may be necessary to directly access the underlying
   * ZipArchive object for implementation-specific logic. This is for advanced
   * use only as it is not shared by other implementations of ArchiveInterface.
   * @return
   *   The ZipArchive object used by this object.
  public function getArchive() {
    return $this->zip;
2 string references to 'ArchiverZip'
og-7.x-1.x.database.php in sites/all/modules/ulmus/og/tests/og-7.x-1.x.database.php
Filled installation of Drupal 7.0, for test purposes.
system_archiver_info in modules/system/system.module
Implements hook_archiver_info().