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


PHP PEAR_PackageFile::addTempFile方法代码示例

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


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

示例1: Archive_Tar

 /**
  * Create a PEAR_PackageFile_v* from a compresed Tar or Tgz file.
  * @access  public
  * @param string contents of package.xml file
  * @param int package state (one of PEAR_VALIDATE_* constants)
  * @return  PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @using   Archive_Tar to extract the files
  * @using   fromPackageFile() to load the package after the package.xml
  *          file is extracted.
  */
 function &fromTgzFile($file, $state)
 {
     if (!class_exists('Archive_Tar')) {
         require_once 'Archive/Tar.php';
     }
     $tar = new Archive_Tar($file);
     if ($this->_debug <= 1) {
         $tar->pushErrorHandling(PEAR_ERROR_RETURN);
     }
     $content = $tar->listContent();
     if ($this->_debug <= 1) {
         $tar->popErrorHandling();
     }
     if (!is_array($content)) {
         if (is_string($file) && strlen($file < 255) && (!file_exists($file) || !@is_file($file))) {
             $ret = PEAR::raiseError("could not open file \"{$file}\"");
             return $ret;
         }
         $file = realpath($file);
         $ret = PEAR::raiseError("Could not get contents of package \"{$file}\"" . '. Invalid tgz file.');
         return $ret;
     } else {
         if (!count($content) && !@is_file($file)) {
             $ret = PEAR::raiseError("could not open file \"{$file}\"");
             return $ret;
         }
     }
     $xml = null;
     $origfile = $file;
     foreach ($content as $file) {
         $name = $file['filename'];
         if ($name == 'package2.xml') {
             // allow a .tgz to distribute both versions
             $xml = $name;
             break;
         }
         if ($name == 'package.xml') {
             $xml = $name;
             break;
         } elseif (ereg('package.xml$', $name, $match)) {
             $xml = $name;
             break;
         }
     }
     if ($this->_tmpdir) {
         $tmpdir = $this->_tmpdir;
     } else {
         $tmpdir = System::mkTemp(array('-d', 'pear'));
         PEAR_PackageFile::addTempFile($tmpdir);
     }
     $this->_extractErrors();
     PEAR::staticPushErrorHandling(PEAR_ERROR_CALLBACK, array($this, '_extractErrors'));
     if (!$xml || !$tar->extractList(array($xml), $tmpdir)) {
         $extra = implode("\n", $this->_extractErrors());
         if ($extra) {
             $extra = ' ' . $extra;
         }
         PEAR::staticPopErrorHandling();
         $ret = PEAR::raiseError('could not extract the package.xml file from "' . $origfile . '"' . $extra);
         return $ret;
     }
     PEAR::staticPopErrorHandling();
     $ret =& PEAR_PackageFile::fromPackageFile("{$tmpdir}/{$xml}", $state, $origfile);
     return $ret;
 }
开发者ID:jamesiarmes,项目名称:php-ups-api,代码行数:75,代码来源:PackageFile.php

示例2: Archive_Tar

 /**
  * Create a PEAR_PackageFile_v* from a compresed Tar or Tgz file.
  * @access  public
  * @param string contents of package.xml file
  * @param int package state (one of PEAR_VALIDATE_* constants)
  * @return  PEAR_PackageFile_v1|PEAR_PackageFile_v2
  * @using   Archive_Tar to extract the files
  * @using   fromPackageFile() to load the package after the package.xml
  *          file is extracted.
  */
 function &fromTgzFile($file, $state)
 {
     if (!class_exists('Archive_Tar')) {
         require_once 'Archive/Tar.php';
     }
     $tar = new Archive_Tar($file);
     if ($this->_debug <= 1) {
         $tar->pushErrorHandling(PEAR_ERROR_RETURN);
     }
     $content = $tar->listContent();
     if ($this->_debug <= 1) {
         $tar->popErrorHandling();
     }
     if (!is_array($content)) {
         if (is_string($file) && strlen($file < 255) && (!file_exists($file) || !@is_file($file))) {
             $ret = PEAR::raiseError("could not open file \"{$file}\"");
             return $ret;
         }
         $file = realpath($file);
         $ret = PEAR::raiseError("Could not get contents of package \"{$file}\"" . '. Invalid tgz file.');
         return $ret;
     }
     if (!count($content) && !@is_file($file)) {
         $ret = PEAR::raiseError("could not open file \"{$file}\"");
         return $ret;
     }
     $sig = null;
     $xml = null;
     $origfile = $file;
     foreach ($content as $file) {
         $name = $file['filename'];
         if (is_null($xml) && ($name == 'package2.xml' || $name == 'package.xml' || preg_match('/package.xml$/', $name, $match))) {
             // allow a .tgz to distribute both versions
             $xml = $name;
         }
         if (is_null($sig) && $name == 'package.sig') {
             $sig = $name;
         }
         if (!is_null($sig) && !is_null($xml)) {
             break;
         }
     }
     $tmpdir = System::mktemp('-t "' . $this->_config->get('temp_dir') . '" -d pear');
     if ($tmpdir === false) {
         $ret = PEAR::raiseError("there was a problem with getting the configured temp directory");
         return $ret;
     }
     PEAR_PackageFile::addTempFile($tmpdir);
     $this->_extractErrors();
     PEAR::staticPushErrorHandling(PEAR_ERROR_CALLBACK, array($this, '_extractErrors'));
     if (!$xml || !$tar->extractList(array_values(array_filter(array($sig, $xml))), $tmpdir)) {
         $extra = implode("\n", $this->_extractErrors());
         if ($extra) {
             $extra = ' ' . $extra;
         }
         PEAR::staticPopErrorHandling();
         $ret = PEAR::raiseError('could not extract the package.xml file from "' . $origfile . '"' . $extra);
         return $ret;
     }
     PEAR::staticPopErrorHandling();
     // Check sig, if it exists.
     if (!is_null($sig)) {
         require_once 'PEAR/Gnupg.php';
         $gnupg = new PEAR_Gnupg($this->_config);
         $result = $gnupg->validateSig("{$tmpdir}/{$xml}", "{$tmpdir}/{$sig}");
         if (PEAR::isError($result)) {
             return $result;
         }
     }
     $ret =& PEAR_PackageFile::fromPackageFile("{$tmpdir}/{$xml}", $state, $origfile);
     return $ret;
 }
开发者ID:cheeepsan,项目名称:pear-core,代码行数:82,代码来源:PackageFile.php


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