本文整理匯總了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;
}