Definition at line 35 of file Zip.php.
◆ __construct()
__construct |
( |
|
$options = null | ) |
|
Class constructor
- Parameters
-
string | array | $options | (Optional) Options to set |
Definition at line 57 of file Zip.php.
59 if (!extension_loaded(
'zip')) {
60 #require_once 'Zend/Filter/Exception.php';
◆ _errorString()
Returns the proper string based on the given error constant
- Parameters
-
Definition at line 269 of file Zip.php.
272 case ZipArchive::ER_MULTIDISK :
273 return 'Multidisk ZIP Archives not supported';
275 case ZipArchive::ER_RENAME :
276 return 'Failed to rename the temporary file for ZIP';
278 case ZipArchive::ER_CLOSE :
279 return 'Failed to close the ZIP Archive';
281 case ZipArchive::ER_SEEK :
282 return 'Failure while seeking the ZIP Archive';
284 case ZipArchive::ER_READ :
285 return 'Failure while reading the ZIP Archive';
287 case ZipArchive::ER_WRITE :
288 return 'Failure while writing the ZIP Archive';
290 case ZipArchive::ER_CRC :
291 return 'CRC failure within the ZIP Archive';
293 case ZipArchive::ER_ZIPCLOSED :
294 return 'ZIP Archive already closed';
296 case ZipArchive::ER_NOENT :
297 return 'No such file within the ZIP Archive';
299 case ZipArchive::ER_EXISTS :
300 return 'ZIP Archive already exists';
302 case ZipArchive::ER_OPEN :
303 return 'Can not open ZIP Archive';
305 case ZipArchive::ER_TMPOPEN :
306 return 'Failure creating temporary ZIP Archive';
308 case ZipArchive::ER_ZLIB :
309 return 'ZLib Problem';
311 case ZipArchive::ER_MEMORY :
312 return 'Memory allocation problem while working on a ZIP Archive';
314 case ZipArchive::ER_CHANGED :
315 return 'ZIP Entry has been changed';
317 case ZipArchive::ER_COMPNOTSUPP :
318 return 'Compression method not supported within ZLib';
320 case ZipArchive::ER_EOF :
321 return 'Premature EOF within ZIP Archive';
323 case ZipArchive::ER_INVAL :
324 return 'Invalid argument for ZLIB';
326 case ZipArchive::ER_NOZIP :
327 return 'Given file is no zip archive';
329 case ZipArchive::ER_INTERNAL :
330 return 'Internal error while working on a ZIP Archive';
332 case ZipArchive::ER_INCONS :
333 return 'Inconsistent ZIP archive';
335 case ZipArchive::ER_REMOVE :
336 return 'Can not remove ZIP Archive';
338 case ZipArchive::ER_DELETED :
339 return 'ZIP Entry has been deleted';
342 return 'Unknown error within ZIP Archive';
◆ compress()
Compresses the given content
- Parameters
-
- Returns
- string Compressed archive
Implements Zend_Filter_Compress_CompressInterface.
Definition at line 124 of file Zip.php.
126 $zip =
new ZipArchive();
127 $res = $zip->open($this->
getArchive(), ZipArchive::CREATE | ZipArchive::OVERWRITE);
130 #require_once 'Zend/Filter/Exception.php'; 135 $content = str_replace(array(
'/',
'\\'), DIRECTORY_SEPARATOR, realpath(
$content));
141 while (!empty($stack)) {
142 $current = array_pop($stack);
145 $dir = dir($current);
146 while (
false !== ($node = $dir->read())) {
147 if (($node ==
'.') || ($node ==
'..')) {
151 if (
is_dir($current . $node)) {
152 array_push($stack, $current . $node . DIRECTORY_SEPARATOR);
155 if (
is_file($current . $node)) {
160 $local = substr($current,
$index);
161 $zip->addEmptyDir(substr($local, 0, -1));
163 foreach (
$files as $file) {
164 $zip->addFile($current . $file, $local . $file);
166 #require_once 'Zend/Filter/Exception.php'; 172 $res = $zip->addFile(
$content, $basename);
174 #require_once 'Zend/Filter/Exception.php'; 181 $file = basename($file);
186 $res = $zip->addFromString($file,
$content);
188 #require_once 'Zend/Filter/Exception.php'; 194 return $this->_options[
'archive'];
foreach($appDirs as $dir) $files
◆ decompress()
Decompresses the given content
- Parameters
-
- Returns
- string
Implements Zend_Filter_Compress_CompressInterface.
Definition at line 203 of file Zip.php.
207 $archive = str_replace(array(
'/',
'\\'), DIRECTORY_SEPARATOR, realpath(
$content));
208 }
elseif (empty($archive) || !file_exists($archive)) {
209 #require_once 'Zend/Filter/Exception.php'; 213 $zip =
new ZipArchive();
214 $res = $zip->open($archive);
227 #require_once 'Zend/Filter/Exception.php'; 232 #require_once 'Zend/Filter/Exception.php'; 236 if (version_compare(PHP_VERSION,
'5.2.8',
'<')) {
237 for (
$i = 0;
$i < $zip->numFiles;
$i++) {
238 $statIndex = $zip->statIndex(
$i);
239 $currName = $statIndex[
'name'];
240 if (($currName{0} ==
'/') ||
241 (substr($currName, 0, 2) ==
'..') ||
242 (substr($currName, 0, 4) ==
'./..')
245 #require_once 'Zend/Filter/Exception.php'; 247 .
' please use PHP 5.2.8 or greater to take advantage of path resolution features of ' 248 .
'the zip extension in this decompress() method.' 254 $res = @$zip->extractTo(
$target);
256 #require_once 'Zend/Filter/Exception.php';
elseif(isset( $params[ 'redirect_parent']))
◆ getArchive()
Returns the set archive
- Returns
- string
Definition at line 71 of file Zip.php.
73 return $this->_options[
'archive'];
◆ getTarget()
Returns the set targetpath
- Returns
- string
Definition at line 95 of file Zip.php.
97 return $this->_options[
'target'];
◆ setArchive()
Sets the archive to use for de-/compression
- Parameters
-
string | $archive | Archive to use |
- Returns
- Zend_Filter_Compress_Rar
Definition at line 82 of file Zip.php.
84 $archive = str_replace(array(
'/',
'\\'), DIRECTORY_SEPARATOR, $archive);
85 $this->_options[
'archive'] = (string) $archive;
◆ setTarget()
Sets the target to use
- Parameters
-
- Returns
- Zend_Filter_Compress_Rar
Definition at line 106 of file Zip.php.
108 if (!file_exists(dirname(
$target))) {
109 #require_once 'Zend/Filter/Exception.php'; 113 $target = str_replace(array(
'/',
'\\'), DIRECTORY_SEPARATOR,
$target);
114 $this->_options[
'target'] = (string)
$target;
◆ toString()
◆ $_options
Initial value:= array(
'archive' => null,
'target' => null,
)
Definition at line 47 of file Zip.php.
The documentation for this class was generated from the following file:
- vendor/magento/zendframework1/library/Zend/Filter/Compress/Zip.php