本文整理汇总了PHP中PharData::isFileFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP PharData::isFileFormat方法的具体用法?PHP PharData::isFileFormat怎么用?PHP PharData::isFileFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PharData
的用法示例。
在下文中一共展示了PharData::isFileFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
<?php
$fname = dirname(__FILE__) . '/' . basename(__FILE__, '.php') . '.zip';
echo "=================== new PharData() ==================\n";
$phar = new PharData($fname);
$phar['a'] = 'a';
$phar['b'] = 'b';
$phar['c'] = 'c';
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());
echo "================= convertToTar() =====================\n";
$phar = $phar->convertToData(Phar::TAR);
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());
echo "================= convertToZip() =====================\n";
$phar = $phar->convertToData(Phar::ZIP, Phar::NONE, '.1.zip');
var_dump($phar->isFileFormat(Phar::PHAR));
var_dump($phar->isFileFormat(Phar::TAR));
var_dump($phar->isFileFormat(Phar::ZIP));
var_dump($phar->getStub());
var_dump($phar->getAlias());
echo "================= convertToPhar() ====================\n";
try {
$phar = $phar->convertToExecutable(Phar::PHAR);
var_dump($phar->isFileFormat(Phar::PHAR));
示例2: archiveExtract
function archiveExtract($srcFile, $destDir, $files = null, $overwrite = true)
{
$result = array();
try {
$archive = new PharData($srcFile);
if ($archive->isFileFormat(Phar::GZ)) {
$archive->decompress('tar');
$srcFile = pathinfo($srcFile, PATHINFO_DIRNAME) . '/' . pathinfo($srcFile, PATHINFO_FILENAME) . '.tar';
unset($archive);
$archive = new PharData($srcFile);
$archive->extractTo($destDir, $files, $overwrite);
} else {
$result[] = _('Unsupported archive format');
}
} catch (Exception $err) {
$result[] = $err;
}
//remove temporary uncompressed tar archive
if (pathinfo($srcFile, PATHINFO_EXTENSION) == 'tar' && is_file($srcFile)) {
unlink($srcFile);
}
return $result;
}