本文整理汇总了PHP中Archive类的典型用法代码示例。如果您正苦于以下问题:PHP Archive类的具体用法?PHP Archive怎么用?PHP Archive使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Archive类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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);
}
开发者ID:Gamepay,项目名称:xp-framework,代码行数:30,代码来源:ArchiveClassLoaderTest.class.php
示例2: create
public function create($paths, $filename = FALSE)
{
$archive = new Archive('tar');
foreach ($paths as $set) {
$archive->add($set[0], $set[1]);
}
$gzfile = bzcompress($archive->create());
if ($filename == FALSE) {
return $gzfile;
}
if (substr($filename, -8) !== '.tar.bz2') {
// Append tar extension
$filename .= '.tar.bz2';
}
// Create the file in binary write mode
$file = fopen($filename, 'wb');
// Lock the file
flock($file, LOCK_EX);
// Write the tar file
$return = fwrite($file, $gzfile);
// Unlock the file
flock($file, LOCK_UN);
// Close the file
fclose($file);
return (bool) $return;
}
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:26,代码来源:Bzip.php
示例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"));
}
开发者ID:Gamepay,项目名称:xp-framework,代码行数:8,代码来源:ArchiveV2Test.class.php
示例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);
}
开发者ID:Gamepay,项目名称:xp-framework,代码行数:16,代码来源:DiffInstruction.class.php
示例5: archive
public function archive($build = FALSE)
{
if ($build === 'build') {
// Load archive
$archive = new Archive('zip');
// Download the application/views directory
$archive->add(APPPATH . 'views/', 'app_views/', TRUE);
// Download the built archive
$archive->download('test.zip');
} else {
echo html::anchor(Router::$current_uri . '/build', 'Download views');
}
}
开发者ID:nicka1711,项目名称:hanami,代码行数:13,代码来源:examples.php
示例6: 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;
}
开发者ID:melogamepay,项目名称:xp-framework,代码行数:53,代码来源:FileSystemScanner.class.php
示例7: on_download
private function on_download()
{
Util::json_fail(Util::ERR_DISABLED, 'download disabled', !$this->context->query_option('download.enabled', false));
$as = $this->request->query('as');
$type = $this->request->query('type');
$base_href = $this->request->query('baseHref');
$hrefs = $this->request->query('hrefs');
$archive = new Archive($this->context);
set_time_limit(0);
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $as . '"');
header('Connection: close');
$ok = $archive->output($type, $base_href, $hrefs);
Util::json_fail(Util::ERR_FAILED, 'packaging failed', !$ok);
exit;
}
开发者ID:Txuritan,项目名称:h5ai,代码行数:16,代码来源:class-api.php
示例8: __construct
public function __construct(\ZipArchive $zipArchive, $tmpFilePath = '/tmp')
{
$tmpFile = tempnam($tmpFilePath, 'zip');
parent::__construct($zipArchive, $tmpFile);
register_shutdown_function(function ($filename) {
unlink($filename);
}, $tmpFile);
}
开发者ID:d9magai,项目名称:phparchive,代码行数:8,代码来源:TmpArchive.php
示例9: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
*
* @param
* integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Archive::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
开发者ID:richardsonlima,项目名称:echofish,代码行数:15,代码来源:ArchiveController.php
示例10: unzip
public function unzip($file)
{
$fh = Loader::helper('file');
$dirBase = parent::unzip($file);
$dirFull = $this->getArchiveDirectory($dirBase);
$dirBase = substr(strrchr($dirFull, '/'), 1);
return $fh->getTemporaryDirectory() . '/' . $file . '/' . $dirBase;
}
开发者ID:holyshared,项目名称:developer-package,代码行数:8,代码来源:importer.php
示例11: afterSaved
public function afterSaved($payload)
{
unset($payload->attributes['created_at']);
unset($payload->attributes['updated_at']);
unset($payload->original['created_at']);
unset($payload->original['updated_at']);
if ($payload->attributes != $payload->original) {
Archive::create(['token' => md5(time()), 'entity_id' => $payload->attributes['id'], 'entity_type' => get_class($payload), 'entity_data' => json_encode($payload->attributes)]);
Log::info(get_class($payload) . ' #' . $payload->attributes['id'] . ' was archived');
}
}
开发者ID:YABhq,项目名称:Quarx,代码行数:11,代码来源:QuarxModel.php
示例12: 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);
}
开发者ID:phellow,项目名称:filesystem,代码行数:31,代码来源:ArchiveTest.php
示例13: finalize
public function finalize($totalSize, $treeHash)
{
$file = $this->getFile('data');
if (($f = fopen($file, 'r+')) === false) {
return false;
}
ftruncate($f, $totalSize);
fclose($f);
$a = new Archive(true, $this->vault);
$a->setParam('SHA256TreeHash', $treeHash);
$a->setParam('Size', $totalSize);
$a->setParam('Description', $this->getParam('Description'));
rename($this->getFile('data'), $a->getFile('data'));
$this->delete();
return $a;
}
开发者ID:sebcode,项目名称:gsandbox,代码行数:16,代码来源:Multipart.php
示例14: 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;
}
}
}
开发者ID:awwthentic1234,项目名称:hey,代码行数:22,代码来源:BannerHub.php
示例15: previewPlan
function previewPlan(&$user, $plan)
{
$timestamp = mktime();
/* format the journalled plan */
if ($this->getPreference('journal')) {
if (!($divider = $this->getPreference('journal_divider'))) {
$divider = PW_DIVIDER;
}
if ($this->getPreference('journal_order') == 'new') {
// show current plan
$tmp = Planworld::getDisplayDivider($divider, $timestamp) . "\n" . $plan . "\n";
// show archived plans
for ($i = 0; $i < $this->getPreference('journal_entries'); $i++) {
list($ts, $txt) = Archive::getEntryByIndex($this->userID, $i);
if ($ts == 0) {
break;
}
$tmp .= Planworld::getDisplayDivider($divider, $ts) . "\n";
$tmp .= $txt . "\n";
}
$plan = $tmp;
} else {
$tmp = '';
for ($i = $this->getPreference('journal_entries') - 1; $i >= 0; $i--) {
list($ts, $txt) = Archive::getEntryByIndex($this->userID, $i);
if ($ts == 0) {
break;
}
$tmp .= Planworld::getDisplayDivider($divider, $ts) . "\n";
$tmp .= $txt . "\n";
}
// show current plan
$tmp .= Planworld::getDisplayDivider($divider, $timestamp) . "\n" . $plan . "\n";
$plan = $tmp;
}
}
return $this->displayPlan($user, $plan);
}
开发者ID:jlodom,项目名称:planworld,代码行数:38,代码来源:User.php
示例16: 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);
}
开发者ID:Gamepay,项目名称:xp-framework,代码行数:11,代码来源:ArchiveTest.class.php
示例17: getArchive
public function getArchive($id)
{
$ret = new Archive($id, $this);
if (!$ret->exists()) {
return false;
}
return $ret;
}
开发者ID:sebcode,项目名称:gsandbox,代码行数:8,代码来源:Vault.php
示例18: Archive
<?php
try {
$Archive = new Archive();
$Archive->setFilename("index.php");
$Archive->setPage($_GET['page'], "page");
if (!$_COOKIE['login']) {
$Archive->setPublic(1);
}
$Archive->DateList();
$AboutMe = array(array("title" => "Information", "info" => array("Alias" => "Compubomb", "Name" => "Robert Kraig", "Height" => "5'11")), array("title" => "Contact", "info" => array("ICQ" => "59128707", "AIM" => "c0mpub0mb", "YIM" => "compubomb", "MSN" => "compubomb at hotmail.com", "Email" => "robertkraig at gmail.com")), array("title" => "Community Sites", "info" => array("myspace.com" => "<a href=\"http://www.myspace.com/compubomb\">Here</a>", "okcupid.com" => "<a href=\"http://www.okcupid.com/profile?u=compubomb\">Here</a>")), array("title" => "Music Genres", "info" => array("Electronic" => "*Trance, Deep House, Disco House, Progressive House, Ibiza/Chillout", "Jazz" => "Smooth, Acid, Traditional", "POP" => "Everything that has a catchy beat")), array("title" => "Music Artists", "info" => array("Trance" => "Armin Van Burrent, DJ Tiesto, Ferry Corsten, Paul Van Dyke, Chicane", "Deep House" => "DJ Mark Farina", "Dream House" => "Robert Miles", "Chillout" => "Cafe Del Mar")), array("title" => "Community Sites", "info" => array("OS" => "Microsoft Windows XP sp3 Pro, Ubuntu", "Graphics" => "Adobe Photoshop CS3", "Desk.Pub" => "Indesign CS3", "Web Dev" => "Adobe Dreamweaver CS3, Zend Studio Eclipse, Notepad++, gvim 7.0")));
$smarty->assign(array("page_name" => "About Me", "load" => "aboutme.tpl", "filename" => $Archive->getFilename(), "archive_index" => $Archive->getIndex(), "sql_queries" => $Archive->getSQLQueries(), "aboutme" => $AboutMe));
$smarty->display('public/body/index.tpl');
echo "<!-- page rendered in approx {$timer->Stop()} -->";
} catch (Exception $e) {
$smarty->assign(array("exception" => $e->getMessage()));
$smarty->display('public/body/error.tpl');
}
开发者ID:robertkraig,项目名称:mycms,代码行数:18,代码来源:AboutMe.php
示例19: create
public static function create($save_path, $files)
{
// Since files can be an array or a path...
if (!is_array($files)) {
$files = array($files);
}
$archive = new Archive();
// Loop through files...(or the one directory/file)
foreach ($files as $file) {
if (file_exists($file)) {
$archive->add($file);
}
}
// Save the file
$archive->save($save_path);
// Status
return file_exists($save_path);
}
开发者ID:enormego,项目名称:EightPHP,代码行数:18,代码来源:zip.php
示例20: on_download
private function on_download()
{
json_fail(1, "downloads disabled", !$this->options["download"]["enabled"]);
$as = use_request_param("as");
$type = use_request_param("type");
$hrefs = use_request_param("hrefs");
$archive = new Archive($this->app);
$hrefs = explode("|:|", trim($hrefs));
set_time_limit(0);
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"{$as}\"");
header("Connection: close");
$rc = $archive->output($type, $hrefs);
json_fail(2, "packaging failed", $rc !== 0);
exit;
}
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:16,代码来源:class-api.php
注:本文中的Archive类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论