本文整理汇总了PHP中Archive_Tar::popErrorHandling方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive_Tar::popErrorHandling方法的具体用法?PHP Archive_Tar::popErrorHandling怎么用?PHP Archive_Tar::popErrorHandling使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Archive_Tar
的用法示例。
在下文中一共展示了Archive_Tar::popErrorHandling方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFileContents
/**
* Get the contents of a file listed within the package.xml
* @param string
* @return string
*/
function getFileContents($file)
{
if ($this->_archiveFile == $this->_packageFile) {
// unpacked
$dir = dirname($this->_packageFile);
$file = $dir . DIRECTORY_SEPARATOR . $file;
$file = str_replace(array('/', '\\'), array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR), $file);
if (file_exists($file) && is_readable($file)) {
return implode('', file($file));
}
} else {
// tgz
if (!class_exists('Archive_Tar')) {
require_once 'Archive/Tar.php';
}
$tar = new Archive_Tar($this->_archiveFile);
$tar->pushErrorHandling(PEAR_ERROR_RETURN);
if ($file != 'package.xml' && $file != 'package2.xml') {
$file = $this->getPackage() . '-' . $this->getVersion() . '/' . $file;
}
$file = $tar->extractInString($file);
$tar->popErrorHandling();
if (PEAR::isError($file)) {
return PEAR::raiseError("Cannot locate file '{$file}' in archive");
}
return $file;
}
}
示例2: realpath
/**
* 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;
}
示例3: doMakeRPM
//.........这里部分代码省略.........
if (isset($deprange[0]) && $excl[$i] == $deprange[0][0]) {
$deprange[0][1] = '<';
unset($dep['exclude'][$i]);
}
if (isset($deprange[1]) && $excl[$i] == $deprange[1][0]) {
$deprange[1][1] = '>';
unset($dep['exclude'][$i]);
}
}
}
if (count($dep['exclude'])) {
$dep['exclude'] = array_values($dep['exclude']);
$newdeprange = array();
// remove excludes that are outside the existing range
for ($i = 0; $i < count($dep['exclude']); $i++) {
if ($dep['exclude'][$i] < $dep['min'] || $dep['exclude'][$i] > $dep['max']) {
unset($dep['exclude'][$i]);
}
}
$dep['exclude'] = array_values($dep['exclude']);
usort($dep['exclude'], 'version_compare');
// take the remaining excludes and
// split the dependency into sub-ranges
$lastmin = $deprange[0];
for ($i = 0; $i < count($dep['exclude']) - 1; $i++) {
$newdeprange[] = '(' . $package . " {$lastmin[1]} {$lastmin[0]} and " . $package . ' < ' . $dep['exclude'][$i] . ')';
$lastmin = array($dep['exclude'][$i], '>');
}
if (isset($dep['max'])) {
$newdeprange[] = '(' . $package . " {$lastmin[1]} {$lastmin[0]} and " . $package . ' < ' . $dep['max'] . ')';
}
$conflicts[] = implode(' or ', $deprange);
} else {
$conflicts[] = $package . " {$deprange[0][1]} {$deprange[0][0]}" . (isset($deprange[1]) ? " and {$package} {$deprange[1][1]} {$deprange[1][0]}" : '');
}
}
continue;
}
if (!isset($dep['min']) && !isset($dep['max']) && !isset($dep['exclude'])) {
if (isset($dep['conflicts'])) {
$conflicts[] = $package;
} else {
$requires[] = $package;
}
} else {
if (isset($dep['min'])) {
$requires[] = $package . ' >= ' . $dep['min'];
}
if (isset($dep['max'])) {
$requires[] = $package . ' <= ' . $dep['max'];
}
if (isset($dep['exclude'])) {
$ex = $dep['exclude'];
if (!is_array($ex)) {
$ex = array($ex);
}
foreach ($ex as $ver) {
$conflicts[] = $package . ' = ' . $ver;
}
}
}
}
require_once 'Archive/Tar.php';
$tar = new Archive_Tar($pf->getArchiveFile());
$tar->pushErrorHandling(PEAR_ERROR_RETURN);
$a = $tar->extractInString('package2.xml');
$tar->popErrorHandling();
if ($a === null || PEAR::isError($a)) {
$info['package2xml'] = '';
// this doesn't have a package.xml version 1.0
$requires[] = 'PEAR::PEAR >= ' . $deps['required']['pearinstaller']['min'];
}
if (count($requires)) {
$info['extra_headers'] .= 'Requires: ' . implode(', ', $requires) . "\n";
}
if (count($conflicts)) {
$info['extra_headers'] .= 'Conflicts: ' . implode(', ', $conflicts) . "\n";
}
}
}
}
// remove the trailing newline
$info['extra_headers'] = trim($info['extra_headers']);
if (function_exists('file_get_contents')) {
fclose($fp);
$spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\\1"]', file_get_contents($spec_template));
} else {
$spec_contents = preg_replace('/@([a-z0-9_-]+)@/e', '$info["\\1"]', fread($fp, filesize($spec_template)));
fclose($fp);
}
$spec_file = "{$info['rpm_package']}-{$info['version']}.spec";
$wp = fopen($spec_file, "wb");
if (!$wp) {
return $this->raiseError("could not write RPM spec file {$spec_file}: {$php_errormsg}");
}
fwrite($wp, $spec_contents);
fclose($wp);
$this->ui->outputData("Wrote RPM spec file {$spec_file}", $command);
return true;
}
示例4: infoFromTgzFile
/**
* Returns information about a package file. Expects the name of
* a gzipped tar file as input.
*
* @param string $file name of .tgz file
*
* @return array array with package information
*
* @access public
*
*/
function infoFromTgzFile($file)
{
if (!@is_file($file)) {
return $this->raiseError("could not open file \"{$file}\"");
}
$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)) {
$file = realpath($file);
return $this->raiseError("Could not get contents of package \"{$file}\"" . '. Invalid tgz file.');
}
$xml = null;
foreach ($content as $file) {
$name = $file['filename'];
if ($name == 'package.xml') {
$xml = $name;
break;
} elseif (ereg('package.xml$', $name, $match)) {
$xml = $match[0];
break;
}
}
$tmpdir = System::mkTemp(array('-d', 'pear'));
$this->addTempFile($tmpdir);
if (!$xml || !$tar->extractList(array($xml), $tmpdir)) {
return $this->raiseError('could not extract the package.xml file');
}
return $this->infoFromDescriptionFile("{$tmpdir}/{$xml}");
}
示例5: array
//.........这里部分代码省略.........
continue;
}
if (isset($dep['conflicts']) && (isset($dep['min']) || isset($dep['max']))) {
$deprange = array();
if (isset($dep['min'])) {
$deprange[] = array($dep['min'], '>=');
}
if (isset($dep['max'])) {
$deprange[] = array($dep['max'], '<=');
}
if (isset($dep['exclude'])) {
if (!is_array($dep['exclude']) || !isset($dep['exclude'][0])) {
$dep['exclude'] = array($dep['exclude']);
}
if (count($deprange)) {
$excl = $dep['exclude'];
// change >= to > if excluding the min version
// change <= to < if excluding the max version
for ($i = 0; $i < count($excl); $i++) {
if (isset($deprange[0]) && $excl[$i] == $deprange[0][0]) {
$deprange[0][1] = '<';
unset($dep['exclude'][$i]);
}
if (isset($deprange[1]) && $excl[$i] == $deprange[1][0]) {
$deprange[1][1] = '>';
unset($dep['exclude'][$i]);
}
}
}
if (count($dep['exclude'])) {
$dep['exclude'] = array_values($dep['exclude']);
$newdeprange = array();
// remove excludes that are outside the existing range
for ($i = 0; $i < count($dep['exclude']); $i++) {
if ($dep['exclude'][$i] < $dep['min'] || $dep['exclude'][$i] > $dep['max']) {
unset($dep['exclude'][$i]);
}
}
$dep['exclude'] = array_values($dep['exclude']);
usort($dep['exclude'], 'version_compare');
// take the remaining excludes and
// split the dependency into sub-ranges
$lastmin = $deprange[0];
for ($i = 0; $i < count($dep['exclude']) - 1; $i++) {
$newdeprange[] = '(' . $package . " {$lastmin[1]} {$lastmin[0]} and " . $package . ' < ' . $dep['exclude'][$i] . ')';
$lastmin = array($dep['exclude'][$i], '>');
}
if (isset($dep['max'])) {
$newdeprange[] = '(' . $package . " {$lastmin[1]} {$lastmin[0]} and " . $package . ' < ' . $dep['max'] . ')';
}
$conflicts[] = implode(' or ', $deprange);
} else {
$conflicts[] = $package . " {$deprange[0][1]} {$deprange[0][0]}" . (isset($deprange[1]) ? " and {$package} {$deprange[1][1]} {$deprange[1][0]}" : '');
}
}
continue;
}
if (!isset($dep['min']) && !isset($dep['max']) && !isset($dep['exclude'])) {
if (isset($dep['conflicts'])) {
$conflicts[] = $package;
} else {
$requires[$package] = $package;
}
} else {
if (isset($dep['min'])) {
$requires[$package] = $package . ' >= ' . $dep['min'];
}
if (isset($dep['max'])) {
$requires[$package] = $package . ' <= ' . $dep['max'];
}
if (isset($dep['exclude'])) {
$ex = $dep['exclude'];
if (!is_array($ex)) {
$ex = array($ex);
}
foreach ($ex as $ver) {
$conflicts[] = $package . ' = ' . $ver;
}
}
}
}
require_once 'Archive/Tar.php';
$tar = new Archive_Tar($pf->getArchiveFile());
$tar->pushErrorHandling(PEAR_ERROR_RETURN);
$a = $tar->extractInString('package2.xml');
$tar->popErrorHandling();
if ($a === null || PEAR::isError($a)) {
$this->_output['package2xml'] = '';
// this doesn't have a package.xml version 1.0
$requires[$this->_output['pear_rpm_name']] = $this->_output['pear_rpm_name'] . ' >= ' . $deps['required']['pearinstaller']['min'];
}
if (count($requires)) {
$this->_output['extra_headers'] .= $this->_formatRpmHeader('Requires', implode(', ', $requires)) . "\n";
}
if (count($conflicts)) {
$this->_output['extra_headers'] .= $this->_formatRpmHeader('Conflicts', implode(', ', $conflicts)) . "\n";
}
}
}
}
示例6: realpath
/**
* 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;
}