本文整理汇总了PHP中Archive::open方法的典型用法代码示例。如果您正苦于以下问题:PHP Archive::open方法的具体用法?PHP Archive::open怎么用?PHP Archive::open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Archive
的用法示例。
在下文中一共展示了Archive::open方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddDirectory
/**
*
*/
public function testAddDirectory()
{
// create test files
$dir = sys_get_temp_dir() . '/testarchive';
$zipfile = sys_get_temp_dir() . '/testarchive.zip';
mkdir($dir);
file_put_contents($dir . '/one.txt', 'one1');
file_put_contents($dir . '/two', 'two2');
mkdir($dir . '/sub');
file_put_contents($dir . '/sub/three.txt', 'three3');
$zip = new Archive();
$zip->open($zipfile, \ZipArchive::CREATE);
$zip->addDirectory($dir);
$zip->close();
$zip = new Archive();
$zip->open($zipfile);
$this->assertEquals('one1', $zip->getFromName('one.txt'));
$this->assertEquals('two2', $zip->getFromName('two'));
$this->assertEquals('three3', $zip->getFromName('sub' . DIRECTORY_SEPARATOR . 'three.txt'));
$zip->close();
// clean up
unlink($dir . '/sub/three.txt');
rmdir($dir . '/sub');
unlink($dir . '/two');
unlink($dir . '/one.txt');
rmdir($dir);
unlink($zipfile);
}
示例2: setUp
/**
* Sets up test case
*
*/
public function setUp()
{
try {
$this->classname = $this->testClassName();
$this->interfacename = $this->testClassName('I');
} catch (IllegalStateException $e) {
throw new PrerequisitesNotMetError($e->getMessage());
}
// Create an archive
$this->tempfile = new TempFile($this->name);
$archive = new Archive($this->tempfile);
$archive->open(ARCHIVE_CREATE);
$this->add($archive, $this->classname, '
uses("util.Comparator", "' . $this->interfacename . '");
class ' . $this->classname . ' extends Object implements ' . $this->interfacename . ', Comparator {
public function compare($a, $b) {
return strcmp($a, $b);
}
}
');
$this->add($archive, $this->interfacename, 'interface ' . $this->interfacename . ' { } ');
$archive->create();
// Setup classloader
$this->classloader = new ArchiveClassLoader($archive);
ClassLoader::getDefault()->registerLoader($this->classloader, TRUE);
}
示例3: readingArchiveV1
public function readingArchiveV1()
{
$a = new Archive($this->getClass()->getPackage()->getResourceAsStream('v1.xar'));
$a->open(ARCHIVE_READ);
$this->assertEquals(1, $a->version);
$this->assertTrue($a->contains('contained.txt'));
$this->assertEntries($a, array('contained.txt' => "This file is contained in an archive!\n"));
}
示例4: perform
/**
* Execute action
*
* @return int
*/
public function perform()
{
$this->archive->open(ARCHIVE_READ);
$args = $this->getArguments();
if (!isset($args[0]) || !file_exists(current($args))) {
throw new IllegalArgumentException('No archive to compare given or not found.');
}
$cmp = new Archive(new File(current($args)));
$cmp->open(ARCHIVE_READ);
return $this->compare($this->archive, $cmp);
}
示例5: 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;
}
示例6: creatingArchive
public function creatingArchive()
{
$contents = array('lang/Object.class.php' => 'class Object { }', 'lang/Type.class.php' => 'class Type extends Object { }');
$a = new Archive(new Stream());
$a->open(ARCHIVE_CREATE);
foreach ($contents as $filename => $bytes) {
$a->addFileBytes($filename, NULL, NULL, $bytes);
}
$a->create();
$this->assertEntries($a, $contents);
}
示例7: __construct
/**
* Constructor
*
* @param lang.archive.Archive archive
* @param string name
*/
public function __construct(Archive $archive, $name)
{
$archive->isOpen() || $archive->open(ARCHIVE_READ);
$this->archive = $archive;
$this->name = $name;
}
示例8: explode
require_once 'archive.php';
// $base_url = "http://127.0.0.1/devdesktop/archive/";
// $base_url = "http://127.0.0.1/devdesktop/archive/archivist/";
$method = $_SERVER['REQUEST_METHOD'];
$request = explode("/", substr(@$_SERVER['PATH_INFO'], 1));
// $request = @$_SERVER['PATH_INFO'];
// var_dump($request);
if (count($request) > 0) {
if ($method === 'GET') {
if ($request[0] === 'listar') {
array_key_exists('path', $_GET) ? $path = $_GET['path'] : ($path = null);
if (Archive::isFolder($path)) {
$reponse = ['type' => 'folder', 'data' => Archive::all($path)];
echo json_encode($reponse);
} else {
$reponse = ['type' => 'file', 'data' => Archive::open($path)];
echo json_encode($reponse);
}
}
if ($request[0] === 'folder') {
echo Archive::isFolder($_GET['url']);
}
} else {
if (isset($_POST) && $method === 'POST') {
if ($request[0] === 'store') {
if (count($_FILES) < 1) {
return "O campo arquivo não pode ser vazio.";
}
return Archive::store($_FILES['arquivo']);
}
} else {