note 80696 added to ref.zip

From: Date: Tue, 29 Jan 2008 14:20:34 +0000
Subject: note 80696 added to ref.zip
Groups: php.notes 
Request: Send a blank email to php-notes+get-135544@lists.php.net to get a copy of this message
Here's a more simple class to add a whole directory recursively, including files and keeping the same structure. It uses SPL. <?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); foreach ($iter as $fileinfo) { if (! $fileinfo->isFile() && !$fileinfo->isDir()) { continue; } $method = $fileinfo->isFile() ? 'addFile' : 'addDir'; $this->$method($fileinfo->getPathname(), $localname . '/' . $fileinfo->getFilename()); } } } ?> ---- Server IP: 200.185.126.110 Probable Submitter: 189.7.156.232 ---- Manual Page -- http://www.php.net/manual/en/ref.zip.php Edit -- https://master.php.net/note/edit/80696 Del: integrated -- https://master.php.net/note/delete/80696/integrated Del: useless -- https://master.php.net/note/delete/80696/useless Del: bad code -- https://master.php.net/note/delete/80696/bad+code Del: spam -- https://master.php.net/note/delete/80696/spam Del: non-english -- https://master.php.net/note/delete/80696/non-english Del: in docs -- https://master.php.net/note/delete/80696/in+docs Del: other reasons-- https://master.php.net/note/delete/80696 Reject -- https://master.php.net/note/reject/80696 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135544) next »