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


PHP PEAR_PackageFile_v1::getPackageFile方法代码示例

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

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

示例1: toTgz

 /**
  * @param PEAR_Packager
  * @param bool if true, a .tgz is written, otherwise a .tar is written
  * @param string|null directory in which to save the .tgz
  * @return string|PEAR_Error location of package or error object
  */
 function toTgz(&$packager, $compress = true, $where = null)
 {
     require_once 'Archive/Tar.php';
     if ($where === null) {
         if (!($where = System::mktemp(array('-d')))) {
             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: mktemp failed');
         }
     } elseif (!@System::mkDir(array('-p', $where))) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: "' . $where . '" could' . ' not be created');
     }
     if (file_exists($where . DIRECTORY_SEPARATOR . 'package.xml') && !is_file($where . DIRECTORY_SEPARATOR . 'package.xml')) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: unable to save package.xml as' . ' "' . $where . DIRECTORY_SEPARATOR . 'package.xml"');
     }
     if (!$this->_packagefile->validate(PEAR_VALIDATE_PACKAGING)) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: invalid package file');
     }
     $pkginfo = $this->_packagefile->getArray();
     $ext = $compress ? '.tgz' : '.tar';
     $pkgver = $pkginfo['package'] . '-' . $pkginfo['version'];
     $dest_package = getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext;
     if (file_exists(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext) && !is_file(getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext)) {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: cannot create tgz file "' . getcwd() . DIRECTORY_SEPARATOR . $pkgver . $ext . '"');
     }
     if ($pkgfile = $this->_packagefile->getPackageFile()) {
         $pkgdir = dirname(realpath($pkgfile));
         $pkgfile = basename($pkgfile);
     } else {
         return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: package file object must ' . 'be created from a real file');
     }
     // {{{ Create the package file list
     $filelist = array();
     $i = 0;
     foreach ($this->_packagefile->getFilelist() as $fname => $atts) {
         $file = $pkgdir . DIRECTORY_SEPARATOR . $fname;
         if (!file_exists($file)) {
             return PEAR::raiseError("File does not exist: {$fname}");
         } else {
             $filelist[$i++] = $file;
             if (!isset($atts['md5sum'])) {
                 $this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($file));
             }
             $packager->log(2, "Adding file {$fname}");
         }
     }
     // }}}
     $packagexml = $this->toPackageFile($where, PEAR_VALIDATE_PACKAGING, 'package.xml', true);
     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 $ok;
         } elseif (!$ok) {
             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
         }
         // ----- Add the content of the package
         if (!$tar->addModify($filelist, $pkgver, $pkgdir)) {
             return PEAR::raiseError('PEAR_Packagefile_v1::toTgz: tarball creation failed');
         }
         return $dest_package;
     }
 }
开发者ID:laiello,项目名称:kangle-php-mysql,代码行数:70,代码来源:v1.php



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