本文整理汇总了PHP中Archive::extract方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive::extract方法的具体用法?PHP Archive::extract怎么用?PHP Archive::extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Archive
的用法示例。
在下文中一共展示了Archive::extract方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExtract
/**
* @param string $destinationFile
* @param string $extensionRequired
* @dataProvider tarProvider
*/
public function testExtract($destinationFile, $extensionRequired)
{
if ($extensionRequired && !extension_loaded($extensionRequired)) {
$this->markTestSkipped("The extension '{$extensionRequired}' is not enabled.");
}
$this->packed = $this->archive->pack($this->sourceFilePath, $this->destinationDir . $destinationFile);
$this->assertFileExists($this->packed);
$this->assertEquals($this->destinationDir . $destinationFile, $this->packed);
$filename = pathinfo($this->sourceFilePath, PATHINFO_BASENAME);
$this->unpacked = $this->archive->extract($filename, $this->packed, $this->destinationDir);
$this->assertFileExists($this->unpacked);
$this->assertStringStartsWith($this->destinationDir, $this->unpacked);
}
示例2: scanDeployments
/**
* Get a list of deployments
*
* @return remote.server.deploy.Deployable[]
*/
public function scanDeployments()
{
clearstatcache();
$this->changed = FALSE;
while ($entry = $this->folder->getEntry()) {
if (!preg_match($this->pattern, $entry)) {
continue;
}
$f = new File($this->folder->getURI() . $entry);
if (isset($this->files[$entry]) && $f->lastModified() <= $this->files[$entry]) {
// File already deployed
continue;
}
$this->changed = TRUE;
$ear = new Archive(new File($this->folder->getURI() . $entry));
try {
$ear->open(ARCHIVE_READ) && ($meta = $ear->extract('META-INF/bean.properties'));
} catch (Throwable $e) {
$this->deployments[$entry] = new IncompleteDeployment($entry, $e);
continue;
}
$prop = Properties::fromString($meta);
$beanclass = $prop->readString('bean', 'class');
if (!$beanclass) {
$this->deployments[$entry] = new IncompleteDeployment($entry, new FormatException('bean.class property missing!'));
continue;
}
$d = new Deployment($entry);
$d->setClassLoader(new ArchiveClassLoader($ear));
$d->setImplementation($beanclass);
$d->setInterface($prop->readString('bean', 'remote'));
$d->setDirectoryName($prop->readString('bean', 'lookup'));
$this->deployments[$entry] = $d;
$this->files[$entry] = time();
delete($f);
}
// Check existing deployments
foreach (array_keys($this->deployments) as $entry) {
$f = new File($this->folder->getURI() . $entry);
if (!$f->exists()) {
unset($this->deployments[$entry], $this->files[$entry]);
$this->changed = TRUE;
}
delete($f);
}
$this->folder->close();
return $this->changed;
}
示例3: codiad_CFG
public function codiad_CFG($hash)
{
$dir_relative = GlobalMas::$filesPath_relative . $hash . "/";
$dir = GlobalMas::$filesPath_absolute . $hash . "/";
//-----------------------------------------------------
if (!file_exists($dir . "codiad")) {
Archive::extract(GlobalMas::$filesPath_absolute . "/codiad.zip", $dir);
//-----------------------------------------------------
$config_contents = FileFolder::file_get_contents($dir . "codiad/config.php");
$config_contents = str_replace("{BASE_PATH}", $dir . "codiad", $config_contents);
$config_contents = str_replace("{BASE_URL}", GenFun::get_full_url($dir . "codiad"), $config_contents);
FileFolder::file_put_contents($dir . "codiad/config.php", $config_contents);
//---------------------------------------------------------
exec("ln -s " . $dir . "compile " . $dir . "codiad/workspace/compile" . " 2>&1", $output);
exec("ln -s " . $dir . " " . $dir . "codiad/workspace/root" . " 2>&1", $output);
//---------------------------------------------------------
if (strpos(join($output), "Errno::") !== false) {
krumo($output);
die;
}
}
}
示例4: extractNonExistant
public function extractNonExistant()
{
$a = new Archive($this->archiveBytesAsStream());
$a->open(ARCHIVE_READ);
$this->assertEquals($this->version(), $a->version);
$a->extract('DOES-NOT-EXIST');
}
示例5: init
public function init($obj)
{
//----------------------------------------------------------
//init var
//----------------------------------------------------------
$chk = array("bool" => true, 'result' => array(), "func" => "init");
//----------------------------------------------------------
if (!is_null($obj)) {
if (isset($obj['zip'])) {
$getFile = GetTable::go("files", array("id" => $obj['zip']));
//------------------------------------------------------
if (!$getFile['bool']) {
return $getFile;
}
if (sizeof($getFile['result']) > 0) {
//--------------------------------------------------
$projectName = $obj['project_name'];
$hash = $getFile['result'][0]['hash'];
$dir_relative = GlobalMas::$filesPath_relative . $hash . "/";
$dir = GlobalMas::$filesPath_absolute . $hash . "/";
$zip_path = $dir . $getFile['result'][0]['name'];
$savePath = dirname($zip_path) . "/compile/" . $projectName . "/";
//-----------------------------------------------------
Archive::extract($zip_path, $this->extractTo = dirname($zip_path) . "/" . FileFolder::getFileName($zip_path));
//-----------------------------------------------------
//if (isset($obj['take_file_name']) && $obj['take_file_name'] == "true") $projectName = FileFolder::getFileName($zip_path);
//-----------------------------------------------------
$url = GenFun::get_full_url(dirname($zip_path) . "/" . rawurlencode(FileFolder::getFileName($zip_path)) . "/");
//-----------------------------------------------------
$bool = $this->htmlExist_CHK($this->extractTo);
}
} else {
if (isset($obj['url']) || is_string($obj)) {
$url = isset($obj['url']) ? $obj['url'] : $obj;
$bool = $this->htmlExist_CHK($url_local = GenFun::get_local_url($url));
//------------------------------------------------------
$output = CurlUtil::go(array("url" => $url));
$projectName = $this->getTitle($output);
//------------------------------------------------------
if (is_null($projectName)) {
$projectName = date("YmdHis");
$hash = alphaID(strtotime($projectName));
$projectName = "untitled_" . $projectName;
}
//------------------------------------------------------
$savePath_relative = $hash . "/" . "compile/" . $projectName . "/";
$savePath = GlobalMas::$filesPath_absolute . $savePath_relative;
/*if (isset($obj['take_file_name']) && $obj['take_file_name'] == "true")*/
$useTitle = true;
} else {
$chk = array();
$chk['bool'] = false;
$chk['error'] = true;
$chk['message'] = $this->notifications_CFG(["message" => "Url could not be obtained!!!"]);
die(json_encode($chk));
}
}
//---------------------------------------------------------
$compiler = $this->compile_CFG($url, $projectName, $savePath);
//---------------------------------------------------------
if (!is_null($compiler->error)) {
return $compiler->error;
}
//---------------------------------------------------------
//$chk['bool'] = true;
// $chk['compiler'] = $compiler;
$notifications = $compiler->compilerGlobal->notifications;
//---------------------------------------------------------
/*if (sizeof($notifications) > 0) {
$chk = $this->deleteFile($getFile['result'][0]['id'], true);
$chk['message'] = $this->notifications_CFG($notifications);
$chk['bool'] = false;
$chk['error'] = true;
return $chk;
}*/
//---------------------------------------------------------
$new_zip_path = Archive::zipDir($compiler->compilePath);
//---------------------------------------------------------
$prop = array();
$prop['hash'] = "{hash}";
$prop['url'] = $url;
$prop['name'] = $projectName;
$prop['dir'] = $savePath_relative;
$prop["filesize"] = FileFolder::getFileSize($new_zip_path);
if (isset($obj['zip'])) {
$prop['files_id'] = $obj['zip'];
}
//---------------------------------------------------------
$chk = InsertINTO::go("compiles", $prop);
//---------------------------------------------------------
$chk['download_link'] = GenFun::get_full_url(Import::$uber_src_path . "server/werm/services/Download.php") . "?url=" . GenFun::get_full_url($new_zip_path);
$chk["filesize"] = $prop["filesize"];
$chk["url"] = $url;
//---------------------------------------------------------
//$chk['project_location'] = GenFun::get_full_url($compiler->compilePath);
}
return $chk;
}
示例6: strtr
#!/usr/bin/env php
<?php
/**
* The installer sub-stub for extension phars
*/
namespace pharext;
define("PHAREXT_PHAR", __FILE__);
spl_autoload_register(function ($c) {
return include strtr($c, "\\_", "//") . ".php";
});
#include <pharext/Exception.php>
#include <pharext/Tempname.php>
#include <pharext/Tempfile.php>
#include <pharext/Tempdir.php>
#include <pharext/Archive.php>
namespace pharext;
if (extension_loaded("Phar")) {
\Phar::interceptFileFuncs();
\Phar::mapPhar();
$phardir = "phar://" . __FILE__;
} else {
$archive = new Archive(__FILE__);
$phardir = $archive->extract();
}
set_include_path("{$phardir}:" . get_include_path());
$installer = new Installer();
$installer->run($argc, $argv);
__halt_compiler();