本文整理汇总了PHP中PEAR_PackageFile_v2::setFileAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP PEAR_PackageFile_v2::setFileAttribute方法的具体用法?PHP PEAR_PackageFile_v2::setFileAttribute怎么用?PHP PEAR_PackageFile_v2::setFileAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PEAR_PackageFile_v2
的用法示例。
在下文中一共展示了PEAR_PackageFile_v2::setFileAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: basename
//.........这里部分代码省略.........
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}");
} else {
$tfile = $packageDir . DIRECTORY_SEPARATOR . $fname;
unset($orig['attribs']);
if (count($orig)) {
// file with tasks
// run any package-time tasks
if (function_exists('file_get_contents')) {
$contents = file_get_contents($file);
} else {
$fp = fopen($file, "r");
$contents = @fread($fp, filesize($file));
fclose($fp);
}
foreach ($orig as $tag => $raw) {
$tag = str_replace($this->_packagefile->getTasksNs() . ':', '', $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);
}
$filelist[$i++] = $tfile;
$this->_packagefile->setFileAttribute($fname, 'md5sum', md5_file($tfile), $i - 1);
$packager->log(2, "Adding file {$fname}");
}
}
}
// }}}
if ($pf1 !== null) {
$name = 'package2.xml';
} else {
$name = '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;
}
}