note 78939 deleted from function.ziparchive-addemptydir by felipe

From: Date: Sun, 16 Dec 2007 11:06:37 +0000
Subject: note 78939 deleted from function.ziparchive-addemptydir by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133640@lists.php.net to get a copy of this message
Note Submitter: nheimann at gmx dot net ---- 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(); } ?>

« previous php.notes (#133640) next »