本文整理汇总了PHP中eZPackage::removeFiles方法的典型用法代码示例。如果您正苦于以下问题:PHP eZPackage::removeFiles方法的具体用法?PHP eZPackage::removeFiles怎么用?PHP eZPackage::removeFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZPackage
的用法示例。
在下文中一共展示了eZPackage::removeFiles方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import
/**
* Imports a package from a gzip compressed tarball file
*
* @param string $archiveName Path to the archive file
* @param string $packageName Package name
* @param bool $dbAvailable
* @param bool $repositoryID
*
* @return eZPackage The eZPackage object if successfull, or one of the
* STATUS_* class constants if an error occurs
*/
static function import($archiveName, &$packageName, $dbAvailable = true, $repositoryID = false)
{
if (is_dir($archiveName)) {
eZDebug::writeError("Importing from directory is not supported.");
$retValue = false;
return $retValue;
} else {
$tempDirPath = eZPackage::temporaryImportPath();
// make a temporary directory to extract the package file to
do {
$archivePath = eZDir::path(array($tempDirPath, mt_rand()));
} while (file_exists($archivePath));
eZDir::mkdir($archivePath, false, true);
$archiveOptions = new ezcArchiveOptions(array('readOnly' => true));
// Fix for issue #15891: ezjscore - file names are cutted
// Force the type of the archive as ezcArchive::TAR_GNU so that long file names are supported on Windows
// The previous value for the second parameter was null which meant the type was guessed from the
// archive, but on Windows it was detected as TAR_USTAR and this lead to filenames being limited
// to 100 characters
$archive = ezcArchive::open("compress.zlib://{$archiveName}", ezcArchive::TAR_GNU, $archiveOptions);
$fileList = array();
$fileList[] = eZPackage::definitionFilename();
// Search for the files we want to extract
foreach ($archive as $entry) {
if (in_array($entry->getPath(), $fileList)) {
if (!$archive->extractCurrent($archivePath)) {
eZDebug::writeError("Failed extracting package definition file from {$archivePath}");
return false;
}
}
}
$definitionFileName = eZDir::path(array($archivePath, self::definitionFilename()));
$package = eZPackage::fetchFromFile($definitionFileName);
eZPackage::removeFiles($archivePath);
if ($package) {
$packageName = $package->attribute('name');
if (!self::isValidName($packageName)) {
return eZPackage::STATUS_INVALID_NAME;
}
if (!$repositoryID) {
$repositoryID = $package->attribute('vendor-dir');
}
$existingPackage = eZPackage::fetch($packageName, false, false, $dbAvailable);
if ($existingPackage) {
return eZPackage::STATUS_ALREADY_EXISTS;
}
unset($package);
$fullRepositoryPath = eZPackage::repositoryPath() . '/' . $repositoryID;
$packagePath = $fullRepositoryPath . '/' . $packageName;
if (!file_exists($packagePath)) {
eZDir::mkdir($packagePath, false, true);
}
$archive->extract($packagePath);
$package = eZPackage::fetch($packageName, $fullRepositoryPath, false, $dbAvailable);
if (!$package) {
eZDebug::writeError("Failed loading imported package {$packageName} from {$fullRepositoryPath}");
}
} else {
eZDebug::writeError("Failed loading temporary package {$packageName}");
}
return $package;
}
}