public function Zip::__construct

public Zip::__construct($file_path)

Constructs a Zip object.

Parameters

string $file_path: The full system path of the archive to manipulate. Only local files are supported. If the file does not yet exist, it will be created if appropriate.

Throws

\Drupal\Core\Archiver\ArchiverException

File

core/lib/Drupal/Core/Archiver/Zip.php, line 29

Class

Zip
Defines a archiver implementation for .zip files.

Namespace

Drupal\Core\Archiver

Code

public function __construct($file_path) {
  $this->zip = new \ZipArchive();
  if ($this->zip->open($file_path) !== TRUE) {
    throw new ArchiverException(t('Cannot open %file_path', array('%file_path' => $file_path)));
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Archiver!Zip.php/function/Zip::__construct/8.1.x