note 78939 added to function.ziparchive-addemptydir
| From: | nheimann at gmx dot net | Date: | Sat, 03 Nov 2007 15:17:50 +0000 |
| Subject: | note 78939 added to function.ziparchive-addemptydir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131965@lists.php.net to get a copy of this message | ||
Extension for ZipArchive. Now you can Add dirs with the Zip Class!
<?php
/**
* FlxZipArchive, Extends ZipArchiv.
* Add Dirs with Files and Subdirs.
*
* <code>
* $archive = new FlxZipArchive;
* // .....
* $archive->addDir( 'test/blub', 'blub' );
*/
class FlxZipArchive extends ZipArchive {
/**
* Add a Dir with Files and Subdirs to the archive
*
* @param string $location Real Location
* @param string $name Name in Archive
* @author Nicolas Heimann
* @access private
**/
public function addDir($location, $name) {
$this->addEmptyDir($name);
$this->addDirDo($location, $name);
// } // EO addDir;
/**
* Add Files & Dirs to archive.
*
* @param string $location Real Location
* @param string $name Name in Archive
* @author Nicolas Heimann
* @access private
**/
private function addDirDo($location, $name) {
$name .= '/';
$location .= '/';
// Read all Files in Dir
$dir = opendir ($location);
while ($file = readdir($dir))
{
if ($file == '.' || $file == '..') continue;
// Rekursiv, If dir: FlxZipArchive::addDir(), else ::File();
$do = (filetype() == 'dir') ? 'addDir' : 'addFile';
$this->$do($location . $file, $name . $file);
}
} // EO addDirDo();
}
?>
----
Server IP: 217.13.201.10
Probable Submitter: 213.39.189.167
----
Manual Page -- http://www.php.net/manual/en/function.ziparchive-addemptydir.php
Edit -- https://master.php.net/note/edit/78939
Del: integrated -- https://master.php.net/note/delete/78939/integrated
Del: useless -- https://master.php.net/note/delete/78939/useless
Del: bad code -- https://master.php.net/note/delete/78939/bad+code
Del: spam -- https://master.php.net/note/delete/78939/spam
Del: non-english -- https://master.php.net/note/delete/78939/non-english
Del: in docs -- https://master.php.net/note/delete/78939/in+docs
Del: other reasons-- https://master.php.net/note/delete/78939
Reject -- https://master.php.net/note/reject/78939
Search -- https://master.php.net/manage/user-notes.php