note 104668 deleted from ref.zip by danbrown
| From: | danbrown@php.net | Date: | Wed, 29 Jun 2011 15:31:21 +0000 |
| Subject: | note 104668 deleted from ref.zip by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-181061@lists.php.net to get a copy of this message | ||
Note Submitter: bart at blueberry dot nl
----
Fix for the endless Iteratore add the flag FilesystemIterator::SKIP_DOTS
<?php
class MyZipArchive extends ZipArchive
{
/**
*
* Adds a directory recursively.
*
* @param string $filename The path to the file to add.
*
* @param string $localname Local name inside ZIP archive.
*
*/
public function addDir($filename, $localname)
{
$this->addEmptyDir($localname);
$iter = new RecursiveDirectoryIterator($filename, FilesystemIterator::SKIP_DOTS);
foreach ($iter as $fileinfo) {
if (! $fileinfo->isFile() && !$fileinfo->isDir()) {
continue;
}
$method = $fileinfo->isFile() ? 'addFile' : 'addDir';
$this->$method($fileinfo->getPathname(), $localname . '/' .
$fileinfo->getFilename());
}
}
}
?>