Source for file release_zip_creator.class.php
Documentation is available at release_zip_creator.class.php
* Contains class Tangra_Module_Installer
* @subpackage modules_manager
* Creates ZIP archive for module release
* @subpackage modules_manager
* Creates ZIP archive for module release
* @param string $source_dir Source dir that contains release files
* @param string $file_path Path to target Zip file to be created
* @param integer $cut Path of source files will be cut from this pos (i.e. path in archive will be what is after $cut)
* @param string $prefix Paths in archive will be prefixed with this value
* @param octal $chmod Created Zip file will be chmoded to this value
* @return boolean Returns true on success, on failure - false
public static function generate_file($source_dir, $file_path, $cut, $prefix, $chmod) {
if ($zip->open($file_path, ZIPARCHIVE::CREATE) === true) {
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source_dir));
foreach ($iterator as $key=> $value) {
if ($c > 100) { //workaround max file descriptors limitation
if (!$zip->addFile(realpath($key), $prefix. substr($key, $cut_from_pos))) {
throw new Tangra_Exception("Cannot add $key to archive");
chmod($file_path, $chmod);
throw new Tangra_Exception('Cannot create '. $file_path);
throw new Tangra_Exception('$source_dir '. $source_dir. ' does not exist or it is not a directory.');
|