当前位置: 首页>>代码示例>>PHP>>正文


PHP Archive_Tar::addModify方法代码示例

本文整理汇总了PHP中Archive_Tar::addModify方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar::addModify方法的具体用法?PHP Archive_Tar::addModify怎么用?PHP Archive_Tar::addModify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Archive_Tar的用法示例。


在下文中一共展示了Archive_Tar::addModify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: archive

 public static function archive($name = false, $listFilesAndFolders, $export_files_dir, $export_files_dir_name, $backupName, $move = false, $identifier, $type)
 {
     if (empty($export_files_dir)) {
         return;
     }
     $dir_separator = DIRECTORY_SEPARATOR;
     $backupName = 'backup' . $dir_separator . $backupName;
     $installFilePath = 'system' . $dir_separator . 'admin-scripts' . $dir_separator . 'miscellaneous' . $dir_separator;
     $dbSQLFilePath = 'backup' . $dir_separator;
     $old_path = getcwd();
     chdir($export_files_dir);
     $tar = new Archive_Tar($backupName, 'gz');
     if (SJB_System::getIfTrialModeIsOn()) {
         $tar->setIgnoreList(array('system/plugins/mobile', 'system/plugins/facebook_app', 'templates/mobile', 'templates/Facebook'));
     }
     SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time())));
     switch ($type) {
         case 'full':
             $tar->addModify("{$installFilePath}install.php", '', $installFilePath);
             $tar->addModify($dbSQLFilePath . $name, '', $dbSQLFilePath);
             $tar->addModify($listFilesAndFolders, '');
             SJB_Filesystem::delete($export_files_dir . $dbSQLFilePath . $name);
             break;
         case 'files':
             $tar->addModify("{$installFilePath}install.php", '', $installFilePath);
             $tar->addModify($listFilesAndFolders, '');
             break;
         case 'database':
             $tar->addModify($dbSQLFilePath . $listFilesAndFolders, '', $dbSQLFilePath);
             SJB_Filesystem::delete($export_files_dir . $dbSQLFilePath . $listFilesAndFolders);
             break;
     }
     chdir($old_path);
     return true;
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:35,代码来源:Backup.php

示例2: create

 /**
  * @param	string	The name of the archive
  * @param	mixed	The name of a single file or an array of files
  * @param	string	The compression for the archive
  * @param	string	Path to add within the archive
  * @param	string	Path to remove within the archive
  * @param	boolean	Automatically append the extension for the archive
  * @param	boolean	Remove for source files
  */
 function create($archive, $files, $compress = 'tar', $addPath = '', $removePath, $autoExt = true)
 {
     $compress = strtolower($compress);
     if ($compress == 'tgz' || $compress == 'tbz' || $compress == 'tar') {
         require_once _EXT_PATH . '/libraries/Tar.php';
         if (is_string($files)) {
             $files = array($files);
         }
         if ($autoExt) {
             $archive .= '.' . $compress;
         }
         if ($compress == 'tgz') {
             $compress = 'gz';
         }
         if ($compress == 'tbz') {
             $compress = 'bz2';
         }
         $tar = new Archive_Tar($archive, $compress);
         $tar->setErrorHandling(PEAR_ERROR_PRINT);
         $result = $tar->addModify($files, $addPath, $removePath);
         return $result;
     } elseif ($compress == 'zip') {
         $adapter =& xFileArchive::getAdapter('zip');
         if ($adapter) {
             $result = $adapter->create($archive, $files, $removePath);
         }
         if ($result == false) {
             return PEAR::raiseError('Unrecoverable ZIP Error');
         }
     }
 }
开发者ID:xamiro-dev,项目名称:xamiro,代码行数:40,代码来源:archive.php

示例3: fopen

 /**
  * The most basic file transaction: add a single entry (file or directory) to
  * the archive.
  *
  * @param bool $isVirtual If true, the next parameter contains file data instead of a file name
  * @param string $sourceNameOrData Absolute file name to read data from or the file data itself is $isVirtual is true
  * @param string $targetName The (relative) file name under which to store the file in the archive
  * @return True on success, false otherwise
  * @since 2.1
  * @access protected
  * @abstract
  */
 function _addFile($isVirtual, &$sourceNameOrData, $targetName)
 {
     if ($isVirtual) {
         // VIRTUAL FILES
         // Create and register temp file with the virtual contents
         $tempFileName = JoomlapackCUBETempfiles::registerTempFile(basename($targetName));
         if (function_exists('file_put_contents')) {
             file_put_contents($tempFileName, $sourceNameOrData);
         } else {
             $tempHandler = fopen($tempFileName, 'wb');
             $this->_fwrite($tempHandler, $sourceNameOrData);
             fclose($tempHandler);
         }
         // Calculate add / remove paths
         $removePath = dirname($tempFileName);
         $addPath = dirname($targetName);
         // Add the file
         $this->_tarObject->addModify($tempFileName, $addPath, $removePath, $tempFileName);
         // Remove the temporary file
         JoomlapackCUBETempfiles::unregisterAndDeleteTempFile(basename($targetName));
     } else {
         // REGULAR FILES
         if ($targetName == '') {
             $targetName = $sourceNameOrData;
         }
         $this->_tarObject->addModify($sourceNameOrData, '', JPATH_SITE, $targetName);
     }
 }
开发者ID:rlee1962,项目名称:diylegalcenter,代码行数:40,代码来源:tar.php

示例4: addToArchive

 public function addToArchive(Archive_Tar $archive)
 {
     $rval = $archive->addModify($this->getBasePath() . DIRECTORY_SEPARATOR . $this->getPath(), null, $this->getBasePath());
     if ($archive->isError($rval)) {
         throw new Engine_Package_Manifest_Exception('Error in archive: ' . $rval->getMessage());
     }
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:7,代码来源:File.php

示例5: foreach

 function _generateTarFile($compress = true)
 {
     $pkgver = (string) $this->xml->name . '-' . (string) $this->xml->version->release;
     $targetdir = !empty($this->options['targetdir']) ? $this->options['targetdir'] . DIRECTORY_SEPARATOR : '';
     $tarname = $targetdir . $pkgver . ($compress ? '.tgz' : '.tar');
     $tar = new Archive_Tar($tarname, $compress);
     $tar->setErrorHandling(PEAR_ERROR_RETURN);
     $result = $tar->create(array($this->pkginfofile));
     if (PEAR::isError($result)) {
         return $this->raiseError($result);
     }
     foreach ($this->files as $roleDir => $files) {
         $result = $tar->addModify($files, $pkgver, $roleDir);
     }
     if (PEAR::isError($result)) {
         return $this->raiseError($result);
     }
     $this->output .= 'Successfully created ' . $tarname . "\n";
     return true;
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:20,代码来源:Mage.php

示例6: basename


//.........这里部分代码省略.........
         // bundles of packages
         $contents = $contents['bundledpackage'];
         if (!isset($contents[0])) {
             $contents = array($contents);
         }
         $packageDir = $where;
         foreach ($contents as $i => $package) {
             $fname = $package;
             $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
             if (!file_exists($file)) {
                 return $packager->raiseError("File does not exist: {$fname}");
             }
             $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
             System::mkdir(array('-p', dirname($tfile)));
             copy($file, $tfile);
             $filelist[$i++] = $tfile;
             $packager->log(2, "Adding package {$fname}");
         }
     } else {
         // normal packages
         $contents = $contents['dir']['file'];
         if (!isset($contents[0])) {
             $contents = array($contents);
         }
         $packageDir = $where;
         foreach ($contents as $i => $file) {
             $fname = $file['attribs']['name'];
             $atts = $file['attribs'];
             $orig = $file;
             $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
             if (!file_exists($file)) {
                 return $packager->raiseError("File does not exist: {$fname}");
             }
             $origperms = fileperms($file);
             $tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
             unset($orig['attribs']);
             if (count($orig)) {
                 // file with tasks
                 // run any package-time tasks
                 $contents = file_get_contents($file);
                 foreach ($orig as $tag => $raw) {
                     $tag = str_replace(array($this->_packagefile->getTasksNs() . ':', '-'), array('', '_'), $tag);
                     $task = "PEAR_Task_{$tag}";
                     $task = new $task($this->_packagefile->_config, $this->_packagefile->_logger, PEAR_TASK_PACKAGE);
                     $task->init($raw, $atts, null);
                     $res = $task->startSession($this->_packagefile, $contents, $tfile);
                     if (!$res) {
                         continue;
                         // skip this task
                     }
                     if (PEAR::isError($res)) {
                         return $res;
                     }
                     $contents = $res;
                     // save changes
                     System::mkdir(array('-p', dirname($tfile)));
                     $wp = fopen($tfile, "wb");
                     fwrite($wp, $contents);
                     fclose($wp);
                 }
             }
             if (!file_exists($tfile)) {
                 System::mkdir(array('-p', dirname($tfile)));
                 copy($file, $tfile);
             }
             chmod($tfile, $origperms);
             $filelist[$i++] = $tfile;
             $this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($tfile), $i - 1);
             $packager->log(2, "Adding file {$fname}");
         }
     }
     // }}}
     $name = $pf1 !== null ? 'package2.xml' : 'package.xml';
     $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, $name);
     if ($packagexml) {
         $tar = new Archive_Tar($dest_package, $compress);
         $tar->setErrorHandling(PEAR_ERROR_RETURN);
         // XXX Don't print errors
         // ----- Creates with the package.xml file
         $ok = $tar->createModify(array($packagexml), '', $where);
         if (PEAR::isError($ok)) {
             return $packager->raiseError($ok);
         } elseif (!$ok) {
             return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): adding ' . $name . ' failed');
         }
         // ----- Add the content of the package
         if (!$tar->addModify($filelist, $pkgver, $where)) {
             return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): tarball creation failed');
         }
         // add the package.xml version 1.0
         if ($pf1 !== null) {
             $pfgen =& $pf1->getDefaultGenerator();
             $packagexml1 = $pfgen->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true);
             if (!$tar->addModify(array($packagexml1), '', $where)) {
                 return $packager->raiseError('PEAR_Packagefile_v2::toTgz(): adding package.xml failed');
             }
         }
         return $dest_package;
     }
 }
开发者ID:michabbb,项目名称:pear-core,代码行数:101,代码来源:v2.php

示例7: createAction

 public function createAction()
 {
     // Require
     require_once 'PEAR.php';
     require_once 'Archive/Tar.php';
     // Form
     $this->view->form = $form = new Install_Form_Backup_Create();
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     // Process
     set_time_limit(0);
     $values = $form->getValues();
     // Make filename
     $archiveFileName = $values['name'];
     $archiveFileName = preg_replace('/[^a-zA-Z0-9_.-]/', '', $archiveFileName);
     if (strtolower(substr($archiveFileName, -4)) != '.tar') {
         $archiveFileName .= '.tar';
     }
     $archiveFileName = $this->_outputPath . DIRECTORY_SEPARATOR . $archiveFileName;
     // setup paths
     $archiveSourcePath = APPLICATION_PATH;
     $tmpPath = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'temporary';
     // Make archive
     $archive = new Archive_Tar($archiveFileName);
     // Add files
     $path = $archiveSourcePath;
     $files = array();
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
     foreach ($it as $file) {
         $pathname = $file->getPathname();
         if ($file->isFile()) {
             if (substr($pathname, 0, strlen($tmpPath)) == $tmpPath) {
                 continue;
             } else {
                 $files[] = $pathname;
             }
         }
     }
     $ret = $archive->addModify($files, '', $path);
     if (PEAR::isError($ret)) {
         throw new Engine_Exception($ret->getMessage());
     }
     // Add temporary structure only
     /*
         $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tmpPath), RecursiveIteratorIterator::SELF_FIRST);
         foreach( $it as $file ) {
      if( $file->isFile() ) {
        continue;
      } else {
        $path = str_replace(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'temporary' . DIRECTORY_SEPARATOR, '', $file->getPathname());
        $path .= DIRECTORY_SEPARATOR . 'index.html';
        $archive->addString($path, '');
      }
         }
     * 
     */
     // Export database
     $dbTempFile = $this->_createTemporaryFile();
     $db = Zend_Registry::get('Zend_Db');
     $export = Engine_Db_Export::factory($db, array());
     $this->_export = $export;
     $export->write($dbTempFile);
     $archive->addString('database.sql', file_get_contents($dbTempFile));
     unlink($dbTempFile);
     return $this->_helper->redirector->gotoRoute(array('action' => 'index'));
 }
开发者ID:robeendey,项目名称:ce,代码行数:70,代码来源:BackupController.php

示例8: usage

        $compression = 'gzup';
    case 'bz2':
        $compression = 'bz2';
    case 'tar':
        $compression = null;
        break;
    default:
        echo "Could not determine archive type for {$archive_file}";
}
$tar = new Archive_Tar($archive_file, $compression);
if (!$tar->create(array())) {
    usage("Could not create tar {$archive_file}");
}
$glob = preg_replace('/(\\*|\\?|\\[)/', '[$1]', $translations_dir . DIRECTORY_SEPARATOR) . '*.pot';
foreach (glob($glob) as $file) {
    if (!$tar->addModify($file, 'translations/' . basename($file, '.pot'), $translations_dir)) {
        usage("Could not add {$base}");
    }
}
echo "Created {$archive_file} with:\n";
$contents = $tar->listContent();
foreach ($contents as $content) {
    echo "\t{$content['filename']}\n";
}
echo "Upload translations by browsing to:\n\t";
echo 'https://translations.edge.launchpad.net/' . $module . '/trunk/+translations-upload' . "\n";
# Local Variables:
# mode: php
# c-default-style: "bsd"
# indent-tabs-mode: nil
# c-basic-offset: 4
开发者ID:apelon-ohie,项目名称:ihris-site,代码行数:31,代码来源:create_launchpad_upload.php

示例9:

 /**
  *
  */
 function _xmlExport($xml)
 {
     $archiveName = 'fabrik_package-' . $this->label;
     require_once JPATH_SITE . '/includes/Archive/Tar.php';
     $archivePath = JPATH_SITE . '/components/com_fabrik/' . $archiveName . '.tgz';
     if (JFile::exists($archivePath)) {
         @unlink($archivePath);
     }
     $zip = new Archive_Tar($archivePath);
     $fileName = $archiveName . '.xml';
     $fileName = $this->_bufferFile;
     //$ok = $zip->addModify('/tmp/' . $fileName, '', "/tmp/");
     //, '', dirname( $fileName)  . "/"
     $fileName = str_replace(JPATH_SITE, '', $this->_bufferFile);
     $fileName = FabrikString::ltrimword($fileName, "/administrator/");
     $ok = $zip->addModify($fileName, '', "components/com_fabrik");
     for ($i = 0; $i < count($this->_aFiles); $i++) {
         $this->_aFiles[$i] = JPATH_SITE . '/components/com_fabrik/tmpl/' . $this->_aFiles[$i];
     }
     $zip->addModify($this->_aFiles, '', JPATH_SITE . '/components/com_fabrik');
     $this->_output_file($archivePath, $archiveName . '.tgz');
 }
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:25,代码来源:export.php

示例10: addToArchive

 public function addToArchive(Archive_Tar $archive)
 {
     if ($this->getAddDirectoryToArchive()) {
         $rval = $archive->addModify($this->getBasePath() . DIRECTORY_SEPARATOR . $this->getPath(), null, $this->getBasePath());
         if ($archive->isError($rval)) {
             throw new Engine_Package_Manifest_Exception('Error in archive: ' . $rval->getMessage());
         }
     } else {
         foreach ($this->getStructure() as $key => $value) {
             $fullpath = $this->getBasePath() . DIRECTORY_SEPARATOR . $this->getPath() . DIRECTORY_SEPARATOR . $value['path'];
             if (is_dir($fullpath)) {
                 continue;
             }
             $rval = $archive->addModify($fullpath, null, $this->getBasePath());
             if ($archive->isError($rval)) {
                 throw new Engine_Package_Manifest_Exception('Error in archive: ' . $rval->getMessage());
             }
         }
     }
 }
开发者ID:robeendey,项目名称:ce,代码行数:20,代码来源:Directory.php

示例11: combineAction

 public function combineAction()
 {
     require_once 'PEAR.php';
     require_once 'Archive/Tar.php';
     $this->view->form = $form = new Install_Form_Sdk_Combine();
     $form->name->setValue('combined_' . time() . '.tar');
     $actions = (array) $this->_getParam('actions');
     foreach ($actions as $index => $action) {
         $path = $this->_outputPath . '/' . $action;
         if (!file_exists($path) || !is_file($path)) {
             unset($actions[$index]);
         }
     }
     if (empty($actions) || !is_array($actions)) {
         return $form->addError('No packages selected.');
     } else {
         if (count($actions) == 1) {
             return $form->addError('Cannot combine only one package.');
         }
     }
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     $archiveFilename = $form->getValue('name');
     $archiveFilename = preg_replace('/[^a-zA-Z0-9_.-]/', '', $archiveFilename);
     if (strtolower(substr($archiveFilename, -4)) != '.tar') {
         $archiveFilename .= '.tar';
     }
     $archive = new Archive_Tar($this->_outputPath . '/' . $archiveFilename);
     foreach ($actions as $action) {
         $path = $this->_outputPath . '/' . $action;
         $archive->addModify($path, null, $this->_outputPath);
     }
     return $this->_helper->redirector->gotoRoute(array('action' => 'manage'));
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:38,代码来源:SdkController.php

示例12: archiveTar

 protected function archiveTar($archiveFile, $items)
 {
     if (!class_exists('Archive_Tar')) {
         return Result::errorMissingPackage($this, 'Archive_Tar', 'pear/archive_tar');
     }
     $tar_object = new \Archive_Tar($archiveFile);
     foreach ($items as $placementLocation => $filesystemLocation) {
         $p_remove_dir = $filesystemLocation;
         $p_add_dir = $placementLocation;
         if (is_file($filesystemLocation)) {
             $p_remove_dir = dirname($filesystemLocation);
             $p_add_dir = dirname($placementLocation);
             if (basename($filesystemLocation) != basename($placementLocation)) {
                 return Result::error($this, "Tar archiver does not support renaming files during extraction; could not add {$filesystemLocation} as {$placementLocation}.");
             }
         }
         if (!$tar_object->addModify([$filesystemLocation], $p_add_dir, $p_remove_dir)) {
             return Result::error($this, "Could not add {$filesystemLocation} to the archive.");
         }
     }
     return Result::success($this);
 }
开发者ID:greg-1-anderson,项目名称:Robo,代码行数:22,代码来源:Pack.php

示例13: create

 /**
  * @param	string	The name of the archive
  * @param	mixed	The name of a single file or an array of files
  * @param	string	The compression for the archive
  * @param	string	Path to add within the archive
  * @param	string	Path to remove within the archive
  * @param	boolean	Automatically append the extension for the archive
  * @param	boolean	Remove for source files
  */
 function create($archive, $files, $compress = 'tar', $addPath = '', $removePath = '', $autoExt = false, $cleanUp = false)
 {
     $compress = strtolower($compress);
     if ($compress == 'tgz' || $compress == 'tbz' || $compress == 'tar') {
         require_once _EXT_PATH . '/libraries/Tar.php';
         if (is_string($files)) {
             $files = array($files);
         }
         if ($autoExt) {
             $archive .= '.' . $compress;
         }
         if ($compress == 'tgz') {
             $compress = 'gz';
         }
         if ($compress == 'tbz') {
             $compress = 'bz2';
         }
         $tar = new Archive_Tar($archive, $compress);
         $tar->setErrorHandling(PEAR_ERROR_PRINT);
         $result = $tar->addModify($files, $addPath, $removePath);
         return $result;
     }
     if ($compress == 'zip') {
         /*require_once( _EXT_PATH.'/libraries/lib_zip.php' );
         		$zip = new ZipFile();
         		$zip->addFileList($files, $removePath );
         		return $zip->save($archive);
         		*/
         require_once _EXT_PATH . '/libraries/Zip.php';
         $zip = new Archive_Zip($archive);
         $result = $zip->add($files, array('add_path' => $addPath, 'remove_path' => $removePath));
         /*require_once( _EXT_PATH.'/libraries/pclzip.lib.php' );
         		$zip = new PclZip($archive);
         		$result = $zip->add($files, PCLZIP_OPT_ADD_PATH, $addPath, PCLZIP_OPT_REMOVE_PATH, $removePath );
         		*/
         if ($result == 0) {
             return new PEAR_Error('Unrecoverable error "' . $zip->errorInfo(true) . '"');
         }
     }
 }
开发者ID:BACKUPLIB,项目名称:mwenhanced,代码行数:49,代码来源:archive.php

示例14: delSvnAndSmartyDir

    $smartyStyle->assign("mediboardScript", CJSLoader::loadFiles());
    $smartyStyle->assign("messages", $messages);
    $smartyStyle->assign("infosystem", CAppUI::pref("INFOSYSTEM"));
    $smartyStyle->assign("errorMessage", CAppUI::getMsg());
    $smartyStyle->assign("uistyle", $uistyle);
    ob_start();
    $smartyStyle->display("header.tpl");
    $smarty->display("repas_offline.tpl");
    $smartyStyle->display("footer.tpl");
    $indexFile = ob_get_contents();
    ob_end_clean();
    file_put_contents("tmp/index.html", $indexFile);
    if ($typeArch == "zip") {
        $zipFile->addFile("tmp/index.html", "index.html");
    } elseif ($typeArch == "tar") {
        $zipFile->addModify("tmp/index.html", null, "tmp/");
    }
}
function delSvnAndSmartyDir($action, $fileProps)
{
    if (preg_match("/.svn/", $fileProps["filename"]) || preg_match("/templates/", $fileProps["filename"]) || preg_match("/templates_c/", $fileProps["filename"])) {
        return false;
    } else {
        return true;
    }
}
function addFiles($src, &$zipFile, $typeArch)
{
    if ($typeArch == "tar") {
        return $zipFile->add("{$src}/", array("callback_pre_add" => "delSvnAndSmartyDir"));
    }
开发者ID:fbone,项目名称:mediboard4,代码行数:31,代码来源:repas_offline.php

示例15: package

 function package($pkgfile = null, $compress = true)
 {
     // {{{ validate supplied package.xml file
     if (empty($pkgfile)) {
         $pkgfile = 'package.xml';
     }
     // $this->pkginfo gets populated inside
     $pkginfo = $this->infoFromDescriptionFile($pkgfile);
     if (PEAR::isError($pkginfo)) {
         return $this->raiseError($pkginfo);
     }
     $pkgdir = dirname(realpath($pkgfile));
     $pkgfile = basename($pkgfile);
     $errors = $warnings = array();
     $this->validatePackageInfo($pkginfo, $errors, $warnings, $pkgdir);
     foreach ($warnings as $w) {
         $this->log(1, "Warning: {$w}");
     }
     foreach ($errors as $e) {
         $this->log(0, "Error: {$e}");
     }
     if (sizeof($errors) > 0) {
         return $this->raiseError('Errors in package');
     }
     // }}}
     $pkgver = $pkginfo['package'] . '-' . $pkginfo['version'];
     // {{{ Create the package file list
     $filelist = array();
     $i = 0;
     foreach ($pkginfo['filelist'] as $fname => $atts) {
         $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
         if (!file_exists($file)) {
             return $this->raiseError("File does not exist: {$fname}");
         } else {
             $filelist[$i++] = $file;
             if (empty($pkginfo['filelist'][$fname]['md5sum'])) {
                 $md5sum = md5_file($file);
                 $pkginfo['filelist'][$fname]['md5sum'] = $md5sum;
             }
             $this->log(2, "Adding file {$fname}");
         }
     }
     // }}}
     // {{{ regenerate package.xml
     $new_xml = $this->xmlFromInfo($pkginfo);
     if (PEAR::isError($new_xml)) {
         return $this->raiseError($new_xml);
     }
     if (!($tmpdir = System::mktemp(array('-d')))) {
         return $this->raiseError("PEAR_Packager: mktemp failed");
     }
     $newpkgfile = $tmpdir . DIRECTORY_SEPARATOR . 'package.xml';
     $np = @fopen($newpkgfile, 'wb');
     if (!$np) {
         return $this->raiseError("PEAR_Packager: unable to rewrite {$pkgfile} as {$newpkgfile}");
     }
     fwrite($np, $new_xml);
     fclose($np);
     // }}}
     // {{{ TAR the Package -------------------------------------------
     $ext = $compress ? '.tgz' : '.tar';
     $dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext;
     $tar = new Archive_Tar($dest_package, $compress);
     $tar->setErrorHandling(PEAR_ERROR_RETURN);
     // XXX Don't print errors
     // ----- Creates with the package.xml file
     $ok = $tar->createModify(array($newpkgfile), '', $tmpdir);
     if (PEAR::isError($ok)) {
         return $this->raiseError($ok);
     } elseif (!$ok) {
         return $this->raiseError('PEAR_Packager: tarball creation failed');
     }
     // ----- Add the content of the package
     if (!$tar->addModify($filelist, $pkgver, $pkgdir)) {
         return $this->raiseError('PEAR_Packager: tarball creation failed');
     }
     $this->log(1, "Package {$dest_package} done");
     if (file_exists("{$pkgdir}/CVS/Root")) {
         $cvsversion = preg_replace('/[^a-z0-9]/i', '_', $pkginfo['version']);
         $cvstag = "RELEASE_{$cvsversion}";
         $this->log(1, "Tag the released code with `pear cvstag {$pkgfile}'");
         $this->log(1, "(or set the CVS tag {$cvstag} by hand)");
     }
     // }}}
     return $dest_package;
 }
开发者ID:radicaldesigns,项目名称:amp,代码行数:86,代码来源:Packager.php


注:本文中的Archive_Tar::addModify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。